PPT.FitGraphicIntoShape: Fit an image into an existing shape

View source: R/graphics.R

PPT.FitGraphicIntoShapeR Documentation

Fit an image into an existing shape

Description

Sometimes shapes serve as placeholders for an image. The function takes a shape, fits an image in its position and deletes the placeholder shape afterwards.

Usage

PPT.FitGraphicIntoShape(
  ppt,
  file,
  shp,
  hjust = "center",
  vjust = "center",
  proportional = TRUE,
  maxscale = 1,
  delete.shape = TRUE,
  ...
)

Arguments

ppt

The ppt object as used in R2PPT.

file

Path to the image file.

shp

Pointer to the shape which the image is fitted into.

hjust, vjust

Horizontal und vertical alignment of image inside frame. Either a string ("center", "left", "right") or ("center", "top", "bottom") or a numerical value between [0,1]. Values bigger than maxscale are used for absolute horizontal und vertical offset.

proportional

Logical (default TRUE). Whether scaling preserves the aspect ratio of the graphic. See details section for additional information.

maxscale

Threshold below which values are interpreted as proportional scaling factors for the width and height argument. Above the threshold values are interpreted as pixels.

delete.shape

Whether to destroy the placeholder shape afterwards (default TRUE).

Examples

## Not run: 

# create new PPT object and add one slide
p <- PPT.Init(visible=T, method = "RDCOMClient")
p <- PPT.AddBlankSlide(p)

# add two rectangle shapes to slide
p <- PPT.AddRectangle(p, width = .4, left=.1)                      # add a shape to slide
p <- PPT.AddRectangle(p, width = .4, left=.5, height=.45, top=.5)  # add a shape to slide

# get all shapes on current slide and replace by image
# shapes are not destroyed to see the image placement
s <- PPT.ShapesOnCurrentSlide(p)   
file <- system.file("image_1.png", package = "R2PPTaddons")  # get image
p <- PPT.FitGraphicIntoShape(p, file, shp=s[[1]], vjust="top", delete.shape =FALSE)
p <- PPT.FitGraphicIntoShape(p, file, shp=s[[2]], vjust="bottom", delete.shape =FALSE)


## End(Not run)





markheckmann/R2PPTaddons documentation built on Oct. 16, 2023, 8:03 p.m.