Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving pptx as pdf in R

Tags:

r

officer

I have created powerpoint files using officer package and I would also like to save them as pdf from R (dont want to manualy open and save as pdf each file). Is this possible?

like image 821
det Avatar asked Feb 04 '26 08:02

det


1 Answers

you can save the powerpoint object edited using the code which is posted here: create pdf in addition to word docx using officer.

You will need to first install pdftools and 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")

Note that the author of the officer package is the one who referred someone to this response.

like image 153
Corey Pembleton Avatar answered Feb 06 '26 00:02

Corey Pembleton