# NOT RUN {
bold_face <- shortcuts$fp_bold(font.size = 30)
bold_redface <- update(bold_face, color = "red")
fpar_ <- fpar(ftext("Hello ", prop = bold_face),
ftext("World", prop = bold_redface ),
ftext(", how are you?", prop = bold_face ) )
doc <- read_docx()
doc <- body_add_fpar(doc, fpar_)
print(doc, target = tempfile(fileext = ".docx"))
# a way of using fpar to center an image in a Word doc ----
rlogo <- file.path( R.home("doc"), "html", "logo.jpg" )
img_in_par <- fpar(
external_img(src = rlogo, height = 1.06/2, width = 1.39/2),
hyperlink_ftext(
href = "https://cran.r-project.org/index.html",
text = "cran", prop = bold_redface),
fp_p = fp_par(text.align = "center") )
doc <- read_docx()
doc <- body_add_fpar(doc, img_in_par)
print(doc, target = tempfile(fileext = ".docx") )
# }
Run the code above in your browser using DataLab