library(officer)
img.file <- file.path(R.home("doc"), "html", "logo.jpg")
bl <- block_list(
fpar(ftext("hello", shortcuts$fp_bold(color = "red"))),
fpar(
ftext("hello world", shortcuts$fp_bold()),
external_img(src = img.file, height = 1.06, width = 1.39),
fp_p = fp_par(text.align = "center")
)
)
doc_1 <- read_docx()
doc_1 <- body_add_blocks(doc_1, blocks = bl)
print(doc_1, target = tempfile(fileext = ".docx"))
Run the code above in your browser using DataLab