addCaption

addCaption

TRIAL / ADVANCED / PREMIUM

Inserts a caption into the Word document.

Description
public addCaption ($text, [array $options] )

This method allows the insertion of a caption into the document.

addImage, addTable and addSVG methods include a caption option to add captions.

Parameters

text

Caption text.

options

The possible keys and values are (required options are shown with yellow background):

Key Type Description
align string Text align.
bookmarkName string Set a custom bookmark name. Default as _GoBack.
color string Text color. HEX value. Default as 1F497D.
fontSize int Text size in half-points. Default as 18.
keepNext bool Keep in the same page the current paragraph with next paragraph. Default as false.
lineSpacing int Text line spacing. Default as 240.
showLabel bool Show default value. Default as true
styleName string Allow setting a custom style name, useful to generate table of figures based on style names. Default as Caption
wrapTextInBookmarks bool Wrap text content between bookmarks. Default as true.

Other styles from createParagraphStyle can be used

Code samples

Example #1

The resulting Word document looks like:

Release notes
  • phpdocx 16.0:
    • new method.