我已经使用 officer 包创建了 powerpoint 文件,我还想将它们从 R 中保存为 pdf(不想手动打开每个文件并将其另存为 pdf)。这可能吗?
最佳答案
您可以保存使用此处发布的代码编辑的 powerpoint 对象:create pdf in addition to word docx using officer .
您需要先安装 pdftools
和 libreoffice
library(pdftools)
office_shot <- function( file, wd = getwd() ){
cmd_ <- sprintf(
"/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf --outdir %s %s",
wd, file )
system(cmd_)
pdf_file <- gsub("\\.(docx|pptx)$", ".pdf", basename(file))
pdf_file
}
office_shot(file = "your_presentation.pptx")
请注意,officer
包的作者是谁 referred有人对此作出回应。
关于r - 在 R 中将 pptx 保存为 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58184764/