customizeWordContent

customizeWordContent

PREMIUM BASIC / ADVANCED

Changes content styles on the fly of documents created from scratch and templates.

Description
public void customizeWordContent(OptionsDOCXPath referenceNode, OptionsDOCXCustomizer options)
Parameters

referenceNode

Option Type Description
target String document (default), style, lastSection.
type String * (all, default value), break, chart, endnote (content reference, the whole paragraph is removed), footnote (content reference, the whole paragraph is removed), image, list, paragraph (also for bookmarks, links and lists), section, shape, table.
contains String Contains a text string.
occurrence String Exact occurrence or range of contents (e.g.: 2..9, 2.., ..9) or first() or last(). If empty iterate all elements.
attributes HashMap<String, String> Contains a specific attribute key and value.
parent String Main document body as default, allows to set any parent or a specific one. w:body (default), '/' (any parent) or any other specific parent (/w:tbl/, /w:tc/, /w:r/...).
customQuery String Custom xpath query, overwrites any other reference.
location String after (default) or default.

options

Changes to be applied.

break elements

Option Type Description
type String line, page

image elements

Option Type Description
borderColor String hexadecimal color: FF0000.
borderStyle String Possible values are:
  • solid
  • dot
  • dash
  • lgDash
  • dashDot
  • lgDashDot
  • lgDashDotDot
  • sysDash
  • sysDot
  • sysDashDot
  • sysDashDotDot
borderWidth Integer Given in emus (1cm = 360000 emus).
height Integer Given in emus (1cm = 360000 emus).
imageAlign string Image alignment: right, center,...
spacingBottom Integer Given in emus (1cm = 360000 emus).
spacingLeft Integer Given in emus (1cm = 360000 emus).
spacingRight Integer Given in emus (1cm = 360000 emus).
spacingTop Integer Given in emus (1cm = 360000 emus).
width Integer Given in emus (1cm = 360000 emus).

list elements. The same options as 'paragraph' and:

Option Type Description
depthLevel Integer Depth level.
type String 0 (clear), 1 (inordinate) (default), 2 (numerical) or the name of the created list.

paragraph elements

Option Type Description
backgroundColor String hexadecimal color: FF0000.
bidi Boolean If true enables bidi.
bold Boolean If true the text will be shown in bold characters.
caps Boolean If true displays text in capital letters.
color String Hexadecimal color value: "FF0000", "000000"...
em String Emphasis mark type: none, dot, circle, comma, underDot.
font String Font family: "Arial", "Calibri"...
fontSize Integer Font size in points.
headingLevel Integer The heading level.
italic Boolean If true displays the text in italics.
lineSpacing Double
  • 1 corresponds to single line spacing
  • 2 to double line spacing and so long so forth
pageBreakBefore Boolean If true forces a page break before the paragraph.
pStyle String Word style to be used. Run parseStyles() method to check all available paragraph styles.
rtl Boolean If true enables RTL.
smallCaps Boolean If true displays text in small capital letters.
spacingBottom Integer Bottom padding in twentieths of a point.
spacingTop Integer Top padding in twentieths of a point.
textAlign String Text alignment within paragraph. Possible values are: center, right, both and distribute.
underline String Underlines text. Possible values are: single, words, double, dotted, dash and wave.
underlineColor String Underlines text with a color: "FF0000", "000000"...

run elements

Option Type Description
bold Boolean If true the text will be shown in bold characters.
caps Boolean If true displays text in capital letters.
characterBorder HashMap<String, String> Adds a border to the character. Keys and values: type => none, single, double, dashed..., color => ffffff, ff0000, spacing => 0, 1, 2..., width => in eights of a point.
color String Hexadecimal color value: "FF0000", "000000"...
em String Emphasis mark type: none, dot, circle, comma, underDot.
font String Font family: 'Arial', Calibri'...
fontSize Integer Font size in points.
highlight String Colors: black, blue, cyan, green, magenta, red, yellow, white, darkBlue, darkCyan, darkGreen, darkMagenta, darkRed, darkYellow, darkGray, lightGray, none.
italic Boolean If true displays the text in italics.
position Integer Position value. Positive value for raised and negative value for lowered.
rtl Boolean If true enables RTL.
scaling Integer Scaling value, 100 is the default value.
smallCaps Boolean If true displays text in small capital letters.
spacing Integer character spacing, positive value for expanded and negative value for condensed.
underline String Underlines text. Possible values are: single, words, double, dotted, dash and wave.
underlineColor String Underlines text using a color: : "FF0000", "000000"...

section elements

Option Type Description
gutter Integer Gutter in twips (used for binding).
height Integer Section height in twips.
marginBottom Integer Bottom margin for this section in twips.
marginFooter Integer Footer margin in twips.
marginHeader Integer Header margin in twips.
marginLeft Integer Left margin for this section in twips.
marginRight Integer Right margin for this section in twips.
marginTop Integer Top margin for this section in twips.
numberCols Integer Number of columns for the section.
orient String Section page orientation (portrait or landscape).
width Integer Section width in twips.

style elements. The same options as "paragraph".

table elements

Option Type Description
border String Border type: none, single, double, dashed, threeDEngrave, threeDEmboss, outset, inset... This value can be overridden for each side with the use "borderTop", "borderRight", "borderBottom" and "borderLeft" properties.
borderColor string Hexadecimal color value: "FF0000", "000000"... This value can be overridden for each side with the use of "borderTopColor", "borderRightColor", "borderBottomColor" and "borderLeftColor" properties.
borderSpacing Integer Border spacing in points. This value can be overridden for each side with the use of "borderTopSpacing", "borderRightSpacing", "borderBottomSpacing" and "borderLeftSpacing" properties.
borderWidth Integer Border size in eigths of a point. This value can be overridden for each side with the use of "borderTopWidth", "borderRightWidth", "borderBottomWidth" and "borderLeftWidth" properties.
cellMargin HashMap<String, String> top, right, bottom and left. The values are given in twentieths of a point.
cellSpacing Integer Separation among cells. Given in twentieths of a point (twips).
columnWidths ArrayList<String> Widths of each column in twentieths of a point.
indent Integer Left table margin in twentieths of a point (twips).
tableAlign String Table alignment. Possible values are: center, left or right.
tableStyle String Word table style id (you may run parseStyles method to check for the available styles in Javadocx or your particular template).
tableWidth HashMap<String, String> Its possible keys and values are:
  • type (pct, dxa) pct if the value refers to percentage and dxa if the value is given in twentieths of a point (twips).
  • value

table-row elements

Option Type Description
height Integer Height in twentieths of a point.
minHeight Integer Minimum height in twentieths of a point.

table-cell elements

Option Type Description
backgroundColor String Hexadecimal color value: "FF0000", "000000"...
border string Border type: none, single, double, dashed, threeDEngrave, threeDEmboss, outset, inset... This value can be overridden for each side with the use "borderTop", "borderRight", "borderBottom" and "borderLeft" properties.
borderColor String Hexadecimal color value: "FF0000", "000000"... This value can be overridden for each side with the use of "borderTopColor", "borderRightColor", "borderBottomColor" and "borderLeftColor" properties.
borderSpacing Integer Border spacing in points. This value can be overridden for each side with the use of "borderTopSpacing", "borderRightSpacing", "borderBottomSpacing" and "borderLeftSpacing" properties.
borderWidth Integer Border size in eigths of a point. This value can be overridden for each side with the use of "borderTopWidth", "borderRightWidth", "borderBottomWidth" and "borderLeftWidth" properties.
cellMargin HashMap<String, String> top, right, bottom and left. The values are given in twentieths of a point.
fitText Boolean If true fits the text to the size of the cell.
rowspan Integer The row span of that particular table cell.
vAlign String Vertical align of text: top, center, both or bottom.
width Integer Preferred cell width in twentieths of a point (twips).

other options

Option Type Description
customAttributes HashMap<String, String> Custom attributes and values.
Code samples

Example #1