且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将 docx 转换为 PDF?

更新时间:2023-01-09 20:28:21

.txt to .pdf

安装 wkhtmltopdf 然后从 R 运行以下命令.根据 wkhtmltopdf 在系统上的位置以及输入和输出文件路径和名称,适当更改前三行.

.txt to .pdf

Install wkhtmltopdf and then from R run the following. Change the first three lines as appropriate depending on where wkhtmltopdf is on your system and depending on the input and output file paths and names.

wkhtmltopdf <- "C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe"
input <- "in.txt"
output <- "out.pdf"
cmd <- sprintf('"%s" "%s" -o "%s"', wkhtmltopdf, input, output)
shell(cmd)

.docx 到 .pdf

安装pandoc,根据需要修改下面的前三行并运行.效果如何可能会因您的输入而异.

.docx to .pdf

Install pandoc, modify the first three lines below as needed and run. How well this works may vary depending on your input.

pandoc <- "C:\\Program Files (x86)\\Pandoc\\pandoc.exe"
input <- "in.docx"
output <- "out.pdf"
cmd <- sprintf('"%s" "%s" -o "%s"', pandoc, input, output)
shell(cmd)