addSlide

addSlide

BASIC / ADVANCED / PREMIUM

Inserts a new slide into the PowerPoint presentation.

Description
public addSlide($options = array())

This method allows the creation of new slides in the PowerPoint presentation.

The layout of the first slide when creating a presentation from scratch is set to 'Title Slide'. This layout can be customized in the new CreatePptx class:

Parameters

options

Key Type Description
active bool If true set as internal active slide. Default as false.
cleanSlidePlaceholderTypes array

Placeholder types to be cleaned from the layout.

Default as: dt, ftr, hdr, sldNum.

Allowed types:

  • title (Title)
  • body (Body)
  • ctrTitle (Centered Title)
  • subTitle (Subtitle)
  • sldNum (Slide Number)
  • ftr (Footer)
  • hdr (Header)
  • obj (Object)
  • chart (Chart)
  • tbl (Table)
  • clipArt (Clip Art)
  • dgm (Diagram)
  • media (Media)
  • sldImg (Slide Image)
  • pic (Picture)
layout string

Layout (name) to be used. If not set, the layout from the active slide is used.

Default layouts:

  • Title Slide
  • Title and Content
  • Section Header
  • Two Content
  • Comparison
  • Title Only
  • Blank
  • Content with Caption
  • Picture with Caption
  • Title and Vertical Text
  • Vertical Title and Text
position int Slide position. 0 is the first slide. -1 (last) as default. If section is set, use this position to add the slide in the section.
section int Section to add the slide. 0 is the first section. -1 is the last section. If not set, the slide is not added in a section.
Exceptions

The layout name doesn't exist.

Code samples

Example #1

The resulting PPTX looks like:

Example #2

The resulting PPTX looks like:

Example #3

The resulting PPTX looks like:

Example #4

The resulting PPTX looks like:

Release notes
  • phppptx 2.0: position and section options.
  • phppptx 1.0: new method.