chuxinyuan Data objects in R can be rendered as HTML tables using the JavaScript library 'DataTables' (typically via R Markdown or Shiny). The 'DataTables' library has been included in this R package. The package name 'DT' is an abbreviation of 'DataTables'. {DT} 貌似先天就是为网页表格而生,利用 {pagedown}生成网页然后用pagedown::chrome_print()打印成 PDF 可能更容易点。
shrektan DT要生成含中文名的PDF也是可以的,但是需要配置下中文字体才行。(不过我鼓捣了10分钟没成功) https://datatables.net/reference/button/pdfHtml5 In addition to this, the PDFMake library must also be available on the page and a suitable font-size. PDFMake provides Roboto in vfs_fonts.js or a custom font can be used. This MIT licensed library provides the ability to create a PDF file in the browser and it utilised by this button.
hulaoda123 步骤一:修改pdfmake.js 找到DT包里的pdfmake.js(DT\htmlwidgets\lib\datatables-extensions\Buttons\js\pdfmake.js),将code里通过查找全部Roboto替换为方正姚体,默认字体也得一起改下 var defaultClientFonts = { 方正姚体: { normal: 'FZYTK.TTF', bold: 'FZYTK.TTF', italics: 'FZYTK.TTF', bolditalics: 'FZYTK.TTF', } }; 步骤二:替换vfs_fonts.js (方正姚体) https://files.cnblogs.com/files/s313139232/方正姚体vfs_fonts.js 注意文件名与原来保持一致
Cloud2016 yihui 可能是我想得太美好了,想象着可以类似网页中在 CSS 里设定字体样式。 hulaoda123 请问一下,如果我是在Shiny中使用 DT,那方正字体是需要访问Shiny应用的用户安装还是开发者在服务端部署的时候安装?
nan.xiao VFS (virtual file system) 这个名字起得还挺好的。看了一下其实就是在一端把二进制文件给编码成 base64 存到 JS 里了,同时大概在另一端做了一个读取的接口。 这个问题和我在写 pkglite 时解决的问题类似。区别在于我只是像 RTF 之类的格式一样,在文本文件嵌入二进制数据时直接存了 hex code,没有使用 base64。