body_add_docx | R Documentation |
Add content of a docx into an rdocx object.
The function is using a 'Microsoft Word' feature: when the document will be edited, the content of the file will be inserted in the main document.
This feature is unlikely to work as expected if the resulting document is edited by another software.
The file is added when the method print()
that
produces the final Word file is called, so don't remove
file defined with src
before.
body_add_docx(x, src, pos = "after")
x |
an rdocx object |
src |
docx filename, the path of the file must not contain any '&' and the basename must not contain any space. |
pos |
where to add the new element relative to the cursor, one of "after", "before", "on". |
Other functions for adding content:
body_add_blocks()
,
body_add_break()
,
body_add_caption()
,
body_add_fpar()
,
body_add_gg()
,
body_add_img()
,
body_add_par()
,
body_add_plot()
,
body_add_table()
,
body_add_toc()
file1 <- tempfile(fileext = ".docx")
file2 <- tempfile(fileext = ".docx")
file3 <- tempfile(fileext = ".docx")
x <- read_docx()
x <- body_add_par(x, "hello world 1", style = "Normal")
print(x, target = file1)
x <- read_docx()
x <- body_add_par(x, "hello world 2", style = "Normal")
print(x, target = file2)
x <- read_docx(path = file1)
x <- body_add_break(x)
x <- body_add_docx(x, src = file2)
print(x, target = file3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.