addTextBox

addTextBox

TRIAL / ADVANCED / PREMIUM

Inserts text boxes into the Word document.

Description
public addTextBox ( mixed $content [, array $options] )

This method allows the insertion of a text box into your Word document.

Parameters

content

It may be a:

  • Word fragment.
  • plain text string.
  • an array with same parameters used in the addText method:
    • the first array entry is the text to be included in the text box.
    • the second one is itself another array with all the standard text formatting options.

options

The possible keys and values are:

Key Type Description
align string center, left, right, absolute, inline.
border int Border width.
borderColor string Hexadecimal value (#ff0000, #0000ff).
borderWidth float value in points.
contentVerticalAlign string top (default), center or bottom.
dashStyle string 'longDashDot', '1 1', '3 1'...
direction string ltr, rtl.
fillColor string Hexadecimal value (#ff0000, #0000ff).
height mixed Height in points or 'auto'.
lineStyle string single, thinThin, thinThick, thickThin, thickBetweenThin
marginTop float Top margin.
marginRight float Right margin.
marginBottom float Bottom margin.
marginLeft float Left margin.
paddingBottom float Distance in cm.
paddingLeft float Distance in mm.
paddingRight float Distance in mm.
paddingTop float Distance in mm.
position string The possible values are: absolute.
relativeToHorizontal string margin, page, text, char.
relativeToVertical string margin, page, text, line.
textboxStyle string Extra textbox styles. Default as 'mso-fit-shape-to-text:t;' if height is 'auto'.
textWrap string tight, square, through, none.
width int Width in points.
z-index int Equivalent to the CSS z-index property. Set a high positive number to make sure that the text box is over other contents.
Code samples

Example #1

The resulting Word document looks like:

Release notes
  • phpdocx 15.5:
    • inline align.
    • textboxStyle and direction options.
  • phpdocx 14.5:
    • marginTop, marginLeft, marginBottom, marginRight, position, relativeToHorizontal, relativeToVertical and z-index options.
  • phpdocx 14.0:
    • dashStyle and lineStyle border styles.
  • phpdocx 12.5:
    • generate an internal v:shapetype tag automatically.