print_docx_pdf: Export a .docx file created using 'officer' package as a .pdf

View source: R/functions.R

print_docx_pdfR Documentation

Export a .docx file created using 'officer' package as a .pdf

Description

This function exports the document as a temporary .docx file, creates a temporary .vbs file with the intended .pdf file name, runs the .vbs file in command prompt, and then deletes the temporary files.

Usage

print_docx_pdf(x, target = NULL, ...)

Arguments

x

document created using 'read_docx()' function from 'officer' package

target

path to the .pdf to be exported, default is a .pdf with the exported object's name in the current working directory

Examples

doc1 <- read_docx()
print_docx_pdf(doc1)
doc2 <- read_docx()
doc2 <- body_add_par(doc2, value = "Table of content", style = "heading 1")
doc2 <- body_add_toc(doc2, level = 2)
doc2 <- body_end_section_continuous(doc2)
doc2 <- body_add_par(doc2, value = "Section 1", style = "heading 1")
doc2 <- body_add_par(doc2, value = "This is a test.", style = "heading 2")
doc2 <- body_add_par(doc2, value = "Section 1", style = "heading 1")
print_docx_pdf(doc2, target = file.path(paste(getwd(),"/test.pdf",sep="")))

joshmire/officerWinTools documentation built on July 5, 2023, 4:27 a.m.