I am trying to automate my PowerPoint reports using the officer package; however, I cannot find out how to customize the text (font size, color, font).
To add in text, I'm using the ph_with()
function. I tried to customize it using officer's ftext()
function, but it doesn't work. With this example
library(officer)
dataframe <- data.frame(column="Sample")
ppt_temp <- read_pptx()
ppt_temp <- add_slide(ppt_temp)
properties <- fp_text(color = "red", font.size = 28, bold = TRUE)
slide_title <- ftext(paste0("These data cover ", dataframe$column[1]), properties)
slide <- ph_with(x = ppt_temp, value = slide_title,
location = ph_location_type(type = "title"))
I get the following error
Error in UseMethod("ph_with", value) :
no applicable method for "ph_with" applied to an object of class "c('ftext', 'cot', 'run')"
If I don't try to set the text properties, this will work
slide <- ph_with(x = ppt_temp, value = paste0("These data cover ", dataframe$column[1]),
location = ph_location_type(type = "title))
Any suggestions?