r - 在 R 中将 pptx 保存为 pdf

标签 r officer

我已经使用 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/

相关文章:

r - 导出data.table并在新行中打印单元格内容

r - 是否可以从 arial 更改 flextable 默认字体

r - 根据外部标准计算一行中的条目数

mysql - Rstudio-server 中的 sql 查询结果为空

r - 如何禁止 “S3 method overwritten”消息打印到用户控制台

r - 在 R 中为引用类创建初始化方法

r - 在 Shiny 的传单 map 上控制点过滤的最有效方法

r - 与官员更改边距