PPT.ReplaceShapeByGraphic | R Documentation |
Looks through all shapes of specified type (default rectangles) and finds shapes with matching text pattern. The shape is replaced by an image.
PPT.ReplaceShapeByGraphic(ppt, what, file, shape.type = 1, ...)
ppt |
The ppt object as used in R2PPT. |
what |
Text pattern to match against. |
file |
Path to the graphic file. |
shape.type |
Shape types in which the text pattern is searched for. By
default only rectangles ( |
... |
Arguments passed on to |
Mark Heckmann
PPT.ReplaceTextByGraphic
## Not run:
# open PPT template
file <- system.file("template.pptx", package = "R2PPTaddons")
ppt <- PPT.Open(file, method="RDCOMClient")
#### CASE 1: ADD GRAPHIC AT TEXTBOX ####
# add graphic to slides with matching text and remove text. Note that by default
# only text in text boxes is replaced. Text inside rectangles, for example, is
# not touched unless explicitly prompted. Note also that additional arguments
# are passed on to PPT.AddGraphicstoSlide2 to specify the position and size of
# the shape.
what <- "[[tag 1]]"
PPT.ReplaceTextByGraphic(ppt, what, file = "inst/image_1.png", width = .6)
# Note that the text appears twice and the graphic is inserted twice with a warning.
what <- "[[tag 2]]"
PPT.ReplaceTextByGraphic(ppt, what, file = "inst/image_2.png")
#### CASE 2: REPLACE SHAPE BY GRAPHIC ####
# replace rectangle with matching text by graphic and move to back
what <- "[[tag 1]]"
PPT.ReplaceShapeByGraphic(ppt, what, file = "inst/image_1.png", z.order = 1)
# Note that additional arguments are passed on to PPT.FitGraphicIntoShape and
# subsequently to PPT.AddGraphicstoSlide2, e.g. to specify the appearance of the image.
what <- "[[tag 2]]"
PPT.ReplaceShapeByGraphic(ppt, what, file = "inst/image_2.png", line.size=1)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.