# NOT RUN {
library(magrittr)
doc <- read_docx() %>%
body_add_par("centered text", style = "centered") %>%
slip_in_text(". How are you", style = "strong") %>%
body_bookmark("text_to_replace") %>%
body_replace_text_at_bkm("text_to_replace", "not left aligned")
# demo usage of bookmark and images ----
template <- system.file(package = "officer", "doc_examples/example.docx")
img.file <- file.path( R.home("doc"), "html", "logo.jpg" )
doc <- read_docx(path = template)
doc <- headers_replace_img_at_bkm(x = doc, bookmark = "bmk_header",
value = external_img(src = img.file, width = .53, height = .7))
doc <- footers_replace_img_at_bkm(x = doc, bookmark = "bmk_footer",
value = external_img(src = img.file, width = .53, height = .7))
print(doc, target = "test_replacement_img.docx")
# }
Run the code above in your browser using DataLab