Guest User

Untitled

a guest
Dec 18th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. library(pdftools)
  2. office_shot <- function( file, wd = getwd() ){
  3. cmd_ <- sprintf(
  4. "/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf --outdir %s %s",
  5. wd, file )
  6. system(cmd_)
  7.  
  8. pdf_file <- gsub("\.(docx|pptx)$", ".pdf", basename(file))
  9. pdf_file
  10. }
  11. office_shot(file = "your_presentation.pptx")
  12.  
  13. library(RDCOMClient)
  14.  
  15. file <- "C:/path/to your/doc.docx"
  16. wordApp <- COMCreate("Word.Application") #creates COM object
  17. wordApp[["Documents"]]$Open(Filename=file) #opens your docx in wordApp
  18. wordApp[["ActiveDocument"]]$SaveAs("C:/path/to your/doc.pdf"), FileFormat=17) #saves as PDF
  19. wordApp$Quit() #quits the COM Word application
Add Comment
Please, Sign In to add comment