addSlide

0th

Percentile

Add a slide into a document object

Add a slide into a document object

Usage
addSlide(doc, ...)
"addSlide"(doc, slide.layout, bookmark, ...)
Arguments
doc
document object
...
further arguments passed to other methods
slide.layout
layout name of the slide to create. See slide.layouts.pptx
bookmark
"integer" page number to specify where slide has to be replaced with a new empty one.
Details

addSlide only works with pptx documents. See addSlide.pptx for examples.
This function is a key function ; if no slide has been added into the document object no content (tables, plots, images, text) can be added.
If creating a slide of type "Title and Content", only one content can be added because there is only one content shape in the layout. If creating a slide of type "Two Content", two content can be added because there are 2 content shapes in the layout.
Content shapes are boxes with dotted borders that hold content in its place on a slide layout. If you need a new layout, create it in PowerPoint :
On the View tab, in the Presentation Views group, click Slide Master.
Function slide.layouts returns available layout names of the template used when pptx object has been created. It is important to know that when using addParagraph.pptx, paragraph and defaut font formats will be defined by the properties of the shape of the slide.layout where content will be added. For example, if you set the shape formatting properties to a 'no bullet', paragraphs of text won't have any bullet.
Also when using addPlot, plot dimensions will be the shape dimensions. It means that if you want to change plot dimensions , this has to be done in the PowerPoint template used when creating the pptx object.

Value

a document object

See Also

pptx, slide.layouts

Aliases
  • addSlide
  • addSlide.pptx
Examples
doc.filename = "addSlide_example.pptx"

options( "ReporteRs-fontsize" = 24 )
doc = pptx( title = "title" )

# add a slide with layout "Title Slide"
doc = addSlide( doc, slide.layout = "Title Slide" )
#set the main title
doc = addTitle( doc, "Presentation title" ) 
#set the sub-title
doc = addSubtitle( doc , "This document is generated with ReporteRs.")

# add a slide with layout "Title and Content" then add content
doc = addSlide( doc, slide.layout = "Title and Content" )
doc = addTitle( doc, "Iris sample dataset", level = 1 )
doc = addFlexTable( doc, vanilla.table( iris[ 1:10,] ) )

# add a slide with layout "Two Content" then add content
doc = addSlide( doc, slide.layout = "Two Content" )
doc = addTitle( doc, "Two Content demo", level = 1 )
doc = addFlexTable( doc, vanilla.table( iris[ 46:55,] ) )
doc = addParagraph(doc, "Hello Word!" )

# to see available layouts :
slide.layouts( doc )

writeDoc( doc, file = doc.filename )

# demo slide replacement --------

# define 2 FlexTables
ft1 = vanilla.table( mtcars[1:6,] , add.rownames = TRUE )
ft2 = vanilla.table( iris[1:10,], add.rownames = TRUE )

# create an doc to be used as template later
mydoc = pptx( )
mydoc = addSlide( mydoc, slide.layout = "Title and Content")
mydoc = addTitle( mydoc, "a table")
mydoc = addFlexTable( mydoc, ft1 )
mydoc = addSlide( mydoc, slide.layout = "Title and Content")
mydoc = addTitle( mydoc, "some text")
mydoc = addParagraph( mydoc, "text example" )
writeDoc( mydoc, "template_example.pptx" )

# use file pp_template_example.pptx as template
# and replace slide 1 
mydoc = pptx(template = "template_example.pptx" )
mydoc = addSlide( mydoc, slide.layout = "Title and Content", bookmark = 1)
mydoc = addTitle( mydoc, "a new table")
mydoc = addFlexTable( mydoc, ft2 )
writeDoc( mydoc, "slide_replacement.pptx" )
Documentation reproduced from package ReporteRs, version 0.8.6, License: GPL-3

Community examples

Looks like there are no examples yet.