createCharacterStyle

createCharacterStyle

TRIAL / ADVANCED / PREMIUM

Creates a new Word character style.

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

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

Parameters

name

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

styleOptions

This is an array including all the available styling options.

Key Type Description
bold bool If true the text will be shown in bold characters.
caps bool If true displays text in capital letters.
characterBorder array 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'...
doubleStrikeThrough bool If true displays text in doubleStrikeThrough.
em string Emphasis mark type: 'none', 'dot', 'circle', 'comma', 'underDot'
emboss bool Emboss style.
font string Font family: 'Arial', Calibri'...
fontSize int Text size in half-points: 8, 9, 10... Multiply by 2 to get the same size as using the fontSize property with addText and other methods.
hidden bool Hide style from user interface.
italic bool If true displays the text in italics.
locked bool Style cannot be applied.
next string Style for next paragraph.
noProof bool Ignore spelling and grammar errors.
outline bool Outline style.
position int Position value. Positive value for raised and negative value for lowered.
semiHidden bool Hide style from main user interface.
shadow bool Shadow style.
strikeThrough bool If true displays text in strikethrough.
subscript bool If true displays text in subscript.
superscript bool If true displays text in superscript.
underline string Underlines text. Possible values are: 'single', 'words', 'double', 'dotted', 'dash' and 'wave'.
unhideWhenUsed bool Remove semi-hidden property when style is used.
vanish bool Uses a vanish style.
vertAlign string Vertical alignment. Possible values are: 'baseline', 'subscript' and 'superscript'.
Code samples

Example #1

The resulting Word document looks like:

Release notes
  • phpdocx 12.5:
    • emboss, noProof, outline, shadow, suppressLineNumbers and vertAlign options.
  • phpdocx 12.0:
    • hidden, semiHidden, unhideWhenUsed, locked and next options.
  • phpdocx 7.5:
    • new method.