I am trying to use the Officer
package to create a docx
. I want to create paragraphs with different levels and text styles while also having each paragraph have its own border. I have tried using fp_par
with both a block_list
command and a fpar
command but with no luck. Any ideas? Here is what I have been trying:
library(officer)
library(dplyr)
reg24 <- fp_text(color = "black", font.size = 24)
bold <- fp_text(color = "black", font.size = 24, bold = TRUE)
underline <- fp_text(color = "black", font.size = 24, underlined = TRUE)
bigbold <- fp_text(color = "black", font.size = 28, bold = TRUE)
border <- fp_par(
text.align = "left",
padding = 0,
border = fp_border(color = "black", style = "solid", width = 1))
summary <- block_list(
fpar(ftext("9", bigbold),
ftext("Address", bold))%>%
fpar(ftext("Status:", underline),
ftext("Under Construction", reg24))%>%
fpar(ftext("Expected Completion:", underline),
ftext("2020", reg24))%>%
fpar(ftext("Investment:", underline),
ftext("$2,000,000")))
I'm not sure where to go from here because it doesn't seem like there is a way to have a paragraph with different levels, different text styles, and a border. Any suggestions?
You can use this example:
library(officer)
library(dplyr)
img.file <- file.path( R.home("doc"), "html", "logo.jpg" )
fpt_blue_bold <- fp_text(color = "#006699", bold = TRUE)
fpt_red_italic <- fp_text(color = "#C32900", italic = TRUE)
border <- fp_par(
text.align = "left",
padding = 0,
border.bottom = fp_border(color = "red", style = "solid", width = 1))
value <- block_list(
fpar(ftext("hello world", fpt_blue_bold), fp_p = border),
fpar(ftext("hello", fpt_blue_bold), " ", ftext("world", fpt_red_italic))
)
read_docx() %>%
body_add_blocks(value) %>%
print(target = "coco.docx")