Inserts a heading into the Word document.


Element definition

This element allows you to insert a heading into your Word document.

If a text is inserted as a heading it will show up in the associated Table of Contents. Please refer to addTableContents for further detail to that respect.

If you wish you may obtain similar results using the addText element with a standard Word heading style.

Attributes and sub-elements


Include the text that you want to be shown in the heading.


An integer specifying the heading level. If not set up explicitely it takes the default value of 1.


The general formating options are:

key Description
pStyle Word style to be used. Run parseStyles() method to check all available paragraph styles
bidi Set to true for right to left languages (default value is false).
bold Bold text: true or false
rtl Set to true for right to left languages (default value is false).
caps Displays text in capital letters: true or false'
color Hexadecimal color value: 'FF0000', '000000'...
contextualSpacing Ignores spacing above and below when using identical styles: 'on' or 'off' (default)
font Font family: 'Arial', Calibri'...
italic Italics: 'on' or 'off'
indentLeft Left margin in points
indentRight Right margin in points
textAlign Text alignment. Possible values are: 'center', 'right', 'both', 'distribute'
keepLines Keeps (whenever possible) all the current paragraph lines on the same page: 'on' or 'off' (default)
keepNext Keeps (whenever possible) in the same page the current paragraph with next paragraph: 'on' or 'off' (default)
lineSpacing Separation between lines: 240 (single spacing), 480 (double spacing and so long so forth.
pageBreakBefore Forces a page break before the paragraph. 'on' or 'off'
spacingBottom Bottom padding in twentieths of a point
spacingTop Top padding in twentieths of a point
fontSize Text size in points: 8, 9, 10...
underline Underlines text. Possible values are: 'single', 'words', 'double', 'dotted', 'dash' and 'wave'
widowControl 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): true or false
wordWrap Controls word wrapping: true or false
Code samples
#Example 1




The resulting Word document looks like: