| print.rdocx | R Documentation |
print.rdocx() is the essential output function for creating Word files
with officer. It takes an rdocx object (created with read_docx() and
populated with content) and writes it to disk as a .docx file.
This function performs all necessary post-processing operations before writing the file.
The function is typically called at the end of your document creation
workflow, after all content has been added with body_add_*() functions.
## S3 method for class 'rdocx'
print(
x,
target = NULL,
copy_header_refs = FALSE,
copy_footer_refs = FALSE,
preview = FALSE,
...
)
x |
an |
target |
path to the |
copy_header_refs, copy_footer_refs |
logical, default is FALSE. If TRUE, copy the references to the header and footer in each section of the body of the document. This parameter is experimental and may change in a future version. |
preview |
Save |
... |
unused |
The full path to the created .docx file (invisibly). This allows
chaining operations or capturing the output path for further use.
Create a 'Word' document object with read_docx(), add content with
functions body_add_par(), body_add_plot(),
body_add_table(), change settings with docx_set_settings(), set
properties with set_doc_properties(), read 'Word' styles with
styles_info().
library(officer)
# This example demonstrates how to create
# an small document -----
## Create a new Word document
doc <- read_docx()
doc <- body_add_par(doc, "hello world")
## Save the document
output_file <- print(doc, target = tempfile(fileext = ".docx"))
# preview mode: save to temp file and open locally ----
## Not run:
print(doc, preview = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.