addLink

addLink

BASIC / ADVANCED / PREMIUM

Inserts a link into the PowerPoint presentation.

Description
public addLink($link, $linkText, $position, $linkStyles = array(), $paragraphStyles = array(), $options = array())

This method inserts a link into the PowerPoint presentation.

This method calls addText to add the new link. A link can also be added using addText with the hyperlink option.

Parameters

link

External link, bookmark (#firstslide, #lastslide, #nextslide, #previousslide) or slide (#slide with position).

linkText

Text Content.

position

Key Type Description
placeholder array

The content is added in a placeholder of the layout. One of the following options can be used to get the text box.

  • 'name' (string) placeholder name.
  • 'descr' (string) placeholder alt text (descr) value.
  • 'position' (int) placeholder position by order. 0 is the first order position.
  • 'type' (string) title (Title), body (Body), ctrTitle (Centered Title), subTitle (Subtitle).
new array

A new position is generated.

  • 'coordinateX' (int) EMUs (English Metric Unit).
  • 'coordinateY' (int) EMUs (English Metric Unit).
  • 'sizeX' (int) EMUs (English Metric Unit).
  • 'sizeY' (int) EMUs (English Metric Unit).
  • 'name' (string) placeholder internal name. If not set, a random name is generated.
  • 'order' (int) set the display order. Default after existing contents. 0 is the first order position. If the order position doesn't exist add after existing contents.
  • 'textBoxStyles' (array) See addTextBox for text box styles.

linkStyles

Array of styles.

Key Type Description
bold bool
characterSpacing int
color string HEX color.
font string Font family.
fontSize int 8, 9, 10, 11...
highlight string HEX color.
italic bool
lang string Language.
strikethrough bool
underline string Underline: single.

paragraphStyles

Key Type Description
align string left, center, right, justify.
lineSpacing int|float 1, 1.5, 2...
noBullet bool No bullet added. Default as true
parseLineBreaks bool If true parses the line breaks. Default as false

options

Key Type Description
insertMode string

Insert mode if the position contains an existing content:

  • append
  • replace

Default as append.

Exceptions

Position not valid.

Hyperlink slide position not valid.

Code samples

Example #1

The resulting PPTX looks like:

Release notes
  • phppptx 3.0:
    • new method.