Creates a new Word paragraph style.

public createParagraphStyle ( string $name [, array $styleOptions = array() ])

This method allows the generation of custom paragraph styles that may be later used in combination with, for example, the addText method.



A string with the name of the Word style that we are creating.


This is an array including all the available styling options.

key Type Description
bold string Bold text: 'on' or 'off'.
border int Hexadecimal color value: 'FF0000', '000000', ...
caps string Display text in capital letters: 'on' or 'off'.
color string Hexadecimal color value: 'FF0000', '000000', ...
contextualSpacing string Ignore spacing above and below when using identical styles: 'on' or 'off' (default).
font string Font family: 'Arial', Calibri', ...
fontSize int Text size in points: 8, 9, 10, ...
hanging int Paragraph hanging in twentieths of a point (twips).
italic string Italics: 'on' or 'off'.
indentLeft int Left margin in twips (twentieths of a point).
indentRight int Right margin in twips (twentieths of a point).
indentFirstLine int Extra indent for the first line of the paragraph.
jc string Text alignment. Possible values are: 'center', 'right', 'both', 'distribute'.
keepLines string Keeps (whenever possible) all the current paragraph lines on the same page: 'on' or 'off' (default).
keepNext string Keeps (whenever possible) in the same page the current paragraph with next paragraph: 'on' or 'off' (default).
lineSpacing int Separation between lines: 240 (single spacing), 480 (double spacing) and so long so forth.
outlineLvl int Heading level (1-9).
pageBreakBefore string Forces a page break before the paragraph. 'on' or 'off'.
pStyle string Id of the style this paragraph style is based on (it may be retrieved with the parseStyles method)
spacingBottom int Bottom padding in twentieths of a point.
spacingTop int Top padding in twentieths of a point.
smallCaps string Displays text in small capital letters: 'on' or 'off'.
tabPositions array Each entry is an associative array with the following keys and values:
  • 'type' (string) can be clear, left (default), center, right, decimal, bar and num,
  • 'leader' (string) can be none (default), dot, hyphen, underscore, heavy and middleDot,
  • 'position' (int) given in twentieths of a point.
If there is a tab and the tabPositions array is not defined the standard tab position (default of 708) will be used.
textDirection string Text flow: lrTb, tbRl, btLr, lrTbV, tbRlV, tbLrV.
underline string Underlines text. Possible values are: 'single', 'words', 'double', 'dotted', 'dash' and 'wave'.
widowControl string Prevents Word from printing the last line of a paragraph by itself at the top of the page (widow) or the first line of a paragraph at the bottom of a page (orphan): 'on' or 'off'.
wordWrap string Allows line breaking at character level: 'on' or 'off' (default).
Return values


Code samples

Example #1

The resulting Word document looks like:

Example #2

The resulting Word document looks like: