pdx:createCharacterStyle

Creates a new Word character style.

Description

Element definition

x
 
1
<pdx:settings>
2
    <pdx:createCharacterStyle pdx:name="" >
3
        <pdx:characterStyle >
4
            <pdx:bold pdx:value="" />
5
            <pdx:caps pdx:value="" />
6
            <pdx:color pdx:value="" />
7
            <pdx:doubleStrikeThrough pdx:value="" />
8
            <pdx:em pdx:value="" />
9
            <pdx:font pdx:value="" />
10
            <pdx:fontSize pdx:value="" />
11
            <pdx:italic pdx:value="" />
12
            <pdx:position pdx:value="" />
13
            <pdx:rtl pdx:value="" />
14
            <pdx:smallCaps pdx:value="" />
15
            <pdx:strikeThrough pdx:value="" />
16
            <pdx:subscript pdx:value="" />
17
            <pdx:superscript pdx:value="" />
18
            <pdx:underline pdx:value="" />
19
            <pdx:vanish pdx:value="" />
20
        </pdx:characterStyle>
21
    </pdx:createCharacterStyle>
22
</pdx:settings>
23

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

Parameters

name

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

key Description
bold Bold text: 'on' or 'off'
caps Displays text in capital letters: 'on' or 'off'
characterBorder Adds a border to the character. Attributes and values: 'type' => none, single, double, dashed..., 'color' => ffffff, ff0000, 'spacing'=> 0, 1, 2..., 'width' => in eights of a point
color Hexadecimal color value: 'FF0000', '000000'...
doubleStrikeThrough If true displays text in doubleStrikeThrough.
em Emphasis mark type: 'none', 'dot', 'circle', 'comma', 'underDot'
font Font family: 'Arial', Calibri'...
fontSize Text size in points: 8, 9, 10...
italic Italics: 'on' or 'off'
position Position value. Positive value for raised and negative value for lowered.
strikeThrough If true displays text in strikethrough.
subscript If true displays text in subscript.
superscript If true displays text in superscript.
underline Underlines text. Possible values are: 'single', 'words', 'double', 'dotted', 'dash' and 'wave'
vanish Uses a vanish style.
Code samples
#Example 1

config.xml

7
 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<pdx:document xmlns:pdx="http://www.phpdocx.com/main">
3
    <pdx:config>
4
        <pdx:output pdx:name="output" pdx:type="docx" />
5
    </pdx:config>
6
</pdx:document>
7

content.xml

20
 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<pdx:document xmlns:pdx="http://www.phpdocx.com/main">
3
    <pdx:content>
4
        <pdx:addText>
5
            <pdx:textRun>
6
                <pdx:data pdx:dataId="" pdx:dataType="text">A text in red color with the character style</pdx:data>
7
                <pdx:textRunStyle>
8
                    <pdx:rStyle pdx:value="myStyle" />
9
                </pdx:textRunStyle>
10
            </pdx:textRun>
11
            <pdx:textRun>
12
                <pdx:data pdx:dataId="" pdx:dataType="text"> other text set as bold but without the character style.</pdx:data>
13
                <pdx:textRunStyle>
14
                    <pdx:bold pdx:value="true" />
15
                </pdx:textRunStyle>
16
            </pdx:textRun>
17
        </pdx:addText>
18
    </pdx:content>
19
</pdx:document>
20

settings.xml

17
 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<pdx:document xmlns:pdx="http://www.phpdocx.com/main">
3
    <pdx:settings>
4
        <pdx:createCharacterStyle pdx:name="myStyle" >
5
            <pdx:characterStyle>
6
                <pdx:bold pdx:value="true" />
7
                <pdx:color pdx:value="ff0000" />
8
                <pdx:font pdx:value="Arial" />
9
                <pdx:fontSize pdx:value="18" />
10
                <pdx:italic pdx:value="true" />
11
                <pdx:position pdx:value="6" />
12
                <pdx:underline pdx:value="single" />
13
            </pdx:characterStyle>
14
        </pdx:createCharacterStyle>
15
    </pdx:settings>
16
</pdx:document>
17
10
 
1
import os as os
2
import sys as sys
3
sys.path.append(os.path.abspath("wrappers/python/XmlDocx"))
4
import XmlDocx as XmlDocx
5
document = XmlDocx.XmlDocx("config.xml")
6
document.setDocumentProperties("settings.xml")
7
document.addContent("content.xml")
8
document.setXmlDocxPath("xmldocx path")
9
document.render()
10