The R officer package is very good at letting you insert text into existing placeholders in a powerpoint deck. For instance, this code:
library(tidyverse)
library(officer)
pres <- (read_pptx()
%>% add_slide(layout = "Title and Content", master = "Office Theme")
%>% ph_with_text(type="body", str="placeholder")
%>% ph_add_par(level=2)
%>% ph_add_text("Foo")
%>% ph_add_par(level=3)
%>% ph_add_text("Bar")
%>% ph_add_par(level=4)
%>% ph_add_text("Baz")
%>% print(target="bullet_example1.pptx"))
produces a powerpoint with bullets that look like this. However, it seems to insert text at an arbitrary location, I have to use the ph_empty_at() function like this:
pres <- (read_pptx()
%>% add_slide(layout = "Title and Content", master = "Office Theme")
%>% ph_empty_at(left=2, top=2, width=5, height=5)
%>% ph_add_par(level=1)
%>% ph_add_text("Placeholder")
%>% ph_add_par(level=2)
%>% ph_add_text("Foo")
%>% ph_add_par(level=3)
%>% ph_add_text("Bar")
%>% ph_add_par(level=4)
%>% ph_add_text("Baz")
%>% print(target="bullet_example2.pptx"))
However, this results in text that looks very different and doesn't respect the levels argument. It seems the text is not inheriting the style from the slide.
I'm asking because I need to use a pre-specified PPT template. I can do this with an existing placeholder, and I get the desired output. How can I insert formatted text like this at an arbitrary location on the slide?