PPT.AddGraphicstoSlide2 | R Documentation |
PPT.AddGraphicstoSlide2
is a modified version of
PPT.AddGraphicstoSlide
from R2PPT. The PPT.AddGraphicstoSlide
function has the drawback that it requires the size of the graphic to be
supplied by the user. If the size is not supplied correctly, the graphic is
deformed. This function keeps the apsect ration intact and offers many
additional features for placing the image on the slide.
PPT.AddGraphicstoSlide2(
ppt,
file,
width = 0.9,
height = 0.8,
left = 0.05,
top = 0.1,
hjust = 0.5,
vjust = 0.5,
frame = list(),
proportional = TRUE,
newslide = TRUE,
maxscale = 1,
display.frame = FALSE,
display.image = TRUE,
line.color = "black",
line.type = 1,
line.size = 0,
shadow.visible = FALSE,
shadow.type = 21,
shadow.color = "black",
shadow.x = 3,
shadow.y = 3,
shadow.transparency = 0.6,
z.order = 0
)
ppt |
The ppt object as used in R2PPT. |
file |
Path to the graphic file. |
width, height |
Width / height of graphic. For values smaller than
|
top, left |
Horizontal und vertical alignment of graphic inside frame.
Either a string ( |
hjust, vjust |
Horizontal und vertical alignment of image inside frame.
Either a string ( |
proportional |
Logical (default |
newslide |
Logical (default is |
maxscale |
Threshold below which values are interpreted as proportional
scaling factors for the |
display.frame |
Add a shape representing the frame into which the image
is placed. This makes it easier when developing new slides (default
|
display.image |
Whether or not the image should be added (default
|
line.color |
Color of text either as hex value or color name. |
line.type |
|
line.size |
Thickness of line (default |
shadow.visible |
Show shadow (default |
shadow.type |
1-20, see MsoShadowType enumeration (default |
shadow.color |
Color of shadow (default |
shadow.x, shadow.y |
Size of shadow. |
shadow.transparency |
Shadow strength. |
z.order |
(numeric). Set z-order. An integer corresponding to the MsoZOrderCmd Enum (e.g. 0 = front, 1 = back). |
The common use case is to add graphics and scale them while preserving
their aspect ratio. In the case this this is not wanted the argument
proportional
can be set to FALSE
. When the aspect ratio is
preserved and both arguments width
and height
are supplied,
the graphic is scaled so that it will not exceed the size given by one of
these values. This is useful when adding a lot of graphics of different
size. Only using width
may result in graphics exceeding the slide
vertically and vice versa. using both parameters (the default) will cause
the graphic to be scaled so it will fit the slide regardless of its
dimensions.
Mark Heckmann
## Not run:
#### EXAMPLE ####
# add PNG that comes with the packages
file <- system.file("image_1.png", package = "R2PPTaddons")
p <- PPT.Init(visible=TRUE, method="RDCOMClient")
p <- PPT.AddGraphicstoSlide2(p, file)
# the argument file is vectorized, so it takes multiple images
folder <- system.file(package = "R2PPTaddons")
files <- list.files(folder, pattern = ".png", full.names = T)
p <- PPT.AddGraphicstoSlide2(p, files)
#### MORE EXAMPLES ####
p <- PPT.Init(visible=TRUE, method="RDCOMClient")
file <- system.file("image_1.png", package = "R2PPTaddons")
# the image is placed within a frame. To get a better understanding
# what happens first only the frame is displayed. Afterwards the image is added.
p <- PPT.AddGraphicstoSlide2(p, file, display.frame = TRUE, display.image = FALSE)
p <- PPT.AddGraphicstoSlide2(p, file, newslide=F)
# width and height values smaller than maxscale (default is 1)
# are interpreted as a proportions of the slide width/height. Values
# greater than 1 are taken as absolute pixel width/height.
p <- PPT.AddGraphicstoSlide2(p, file, width=.5)
p <- PPT.AddGraphicstoSlide2(p, file, height=.5)
# using pixel width/height instead of proportions of
# available slide width/height
p <- PPT.AddGraphicstoSlide2(p, file, width=400)
p <- PPT.AddGraphicstoSlide2(p, file, width=400, left=0)
# one can also fit the image completely to the frame potentially
# destroying the image's aspect ration, i.e. distorting it
p <- PPT.AddGraphicstoSlide2(p, file, width=400, height=100, proportional=FALSE)
# position the image on slide
p <- PPT.AddGraphicstoSlide2(p, file, left=0, width =.5)
p <- PPT.AddGraphicstoSlide2(p, file, top=0, height =.5)
# aligment of image inside the frame
p <- PPT.AddGraphicstoSlide2(p, file, width=400, display.frame = T)
p <- PPT.AddGraphicstoSlide2(p, file, width=400, vjust="top",display.frame = T)
p <- PPT.AddGraphicstoSlide2(p, file, width=400, vjust=0,display.frame = T)
p <- PPT.AddGraphicstoSlide2(p, file, width=400, vjust="bottom",display.frame = T)
p <- PPT.AddGraphicstoSlide2(p, file, width=400, vjust=1, display.frame = T)
p <- PPT.AddGraphicstoSlide2(p, file, width=400, vjust=400, display.frame = T)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.