body_remove {officer} | R Documentation |
remove element pointed by cursor from a Word document
body_remove(x)
x |
an rdocx object |
library(officer) library(magrittr) str1 <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " %>% rep(20) %>% paste(collapse = "") str2 <- "Drop that text" str3 <- "Aenean venenatis varius elit et fermentum vivamus vehicula. " %>% rep(20) %>% paste(collapse = "") my_doc <- read_docx() %>% body_add_par(value = str1, style = "Normal") %>% body_add_par(value = str2, style = "centered") %>% body_add_par(value = str3, style = "Normal") new_doc_file <- print(my_doc, target = tempfile(fileext = ".docx")) my_doc <- read_docx(path = new_doc_file) %>% cursor_reach(keyword = "that text") %>% body_remove() print(my_doc, target = tempfile(fileext = ".docx"))