在 R 中将 pptx 保存为 pdf

det*_*det 1 r officer

我已经使用官员包创建了 powerpoint 文件,我还想将它们保存为 R 中的 pdf(不想手动打开每个文件并将其另存为 pdf)。这可能吗?

Cor*_*ton 6

您可以保存使用此处发布的代码编辑的 powerpoint 对象:除了 word docx 之外,还使用官员创建 pdf。

您需要先安装pdftoolslibreoffice

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")
Run Code Online (Sandbox Code Playgroud)

请注意,笔者officer包是谁的一个提到有人对此的回应。