officer (version 0.3.6)

ph_with_text: add text into a new shape

Description

add text into a new shape in a slide. This function will be deprecated in favor of ph_with in the next release.

Usage

ph_with_text(x, str, type = "title", index = 1, location = NULL)

Arguments

x

an pptx object

str

text to add

type

placeholder type (i.e. 'body', 'title')

index

placeholder index (integer). This is to be used when a placeholder type is not unique in the current slide, e.g. two placeholders with type 'body', the first one will be added with index 1 and the second one with index 2. It is recommanded to use argument location instead of type and index.

location

a placeholder location object. This is a convenient argument that can replace usage of arguments type and index. See ph_location_type, ph_location, ph_location_label, ph_location_left, ph_location_right, ph_location_fullsize.

Examples

Run this code
# NOT RUN {
# define locations for placeholders ----
loc_title <- ph_location_type(type = "title")
loc_footer <- ph_location_type(type = "ftr")
loc_dt <- ph_location_type(type = "dt")
loc_slidenum <- ph_location_type(type = "sldNum")
loc_body <- ph_location_type(type = "body")


doc <- read_pptx()
doc <- add_slide(doc)
doc <- ph_with(x = doc, "Un titre", location = loc_title)
doc <- ph_with(x = doc, "pied de page", location = loc_footer)
doc <- ph_with(x = doc, format(Sys.Date()), location = loc_dt)
doc <- ph_with(x = doc, "slide 1", location = loc_slidenum)
doc <- ph_with(x = doc, letters[1:10], location = loc_body)

loc_subtitle <- ph_location_type(type = "subTitle")
loc_ctrtitle <- ph_location_type(type = "ctrTitle")
doc <- add_slide(doc, layout = "Title Slide", master = "Office Theme")
doc <- ph_with(x = doc, "Un sous titre", location = loc_subtitle)
doc <- ph_with(x = doc, "Un titre", location = loc_ctrtitle)

fileout <- tempfile(fileext = ".pptx")
print(doc, target = fileout )
# }

Run the code above in your browser using DataLab