【问题标题】:Saving pptx as pdf in R在R中将pptx保存为pdf
【发布时间】:2021-05-30 03:25:52
【问题描述】:

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

【问题讨论】:

  • 你使用的是什么操作系统?

标签: r officer


【解决方案1】:

您可以保存使用此处发布的代码编辑的 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 某人对此回复的人。

【讨论】:

【解决方案2】:

请注意,the answer from Corey Pembleton 具有 LibreOffice iOS 路径。 (我个人最初并没有注意到)。 Windows 路径类似于"C:/Program Files/LibreOffice/program/soffice.exe"

由于Corey提供的初始答案,使用docxtractr::convert_to_pdfcan now be found here的示例。 包和函数是John M commented in Corey initial answer

【讨论】:

    猜你喜欢
    • 2020-01-30
    • 2015-07-11
    • 1970-01-01
    • 1970-01-01
    • 2020-10-31
    • 2011-01-17
    • 2017-06-02
    • 1970-01-01
    • 2017-05-27
    相关资源
    最近更新 更多