pdx:addPageBorders

Adds custom page borders to the current Word document.

Description

Element definition

x
 
1
<pdx:settings>
2
    <pdx:addPageBorders pdx:display="" pdx:color="" pdx:space="" pdx:style="" pdx:width="" pdx:offsetFrom="" pdx:zOrder="">
3
        <pdx:top pdx:color="" pdx:space="" pdx:style="" pdx:width="" />
4
        <pdx:right pdx:color="" pdx:space="" pdx:style="" pdx:width="" />
5
        <pdx:bottom pdx:color="" pdx:space="" pdx:style="" pdx:width="" />
6
        <pdx:left pdx:color="" pdx:space="" pdx:style="" pdx:width="" />
7
    </pdx:addPageBorders>
8
</pdx:settings>
9

This element allows you to insert page borders into the Word document.

Attributes and sub-elements
key Description
display
  • allPages (displays page border on all pages: default value),
  • firstPage (displays page border on first page),
  • notFirstPage (displays page border on all pages except first).
color Border hexadecimal color ('000000' (default), 'FF0000', ...)
offsetFrom Possible values are: 'page' or 'text'
space Border spacing in points (default is 24)
style Border. It can be none, single (default), double, ... See, for example, http://www.schemacentral.com/sc/ooxml/t-w_ST_Border.html for a complete list of border available styles
width Page border width in eigths of a point (default value is 4)
zOrder Sets the z-index of the border
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">This is just a chunk of text that we will repeat couple of times to fill up some space. This is just a chunk of text that we will repeat couple of times to fill up some space.</pdx:data>
7
                <pdx:textRunStyle>
8
                </pdx:textRunStyle>
9
            </pdx:textRun>
10
        </pdx:addText>
11
        <pdx:addText>
12
            <pdx:textRun>
13
                <pdx:data pdx:dataId="" pdx:dataType="text">Another chunk of text</pdx:data>
14
                <pdx:textRunStyle>
15
                </pdx:textRunStyle>
16
            </pdx:textRun>
17
        </pdx:addText>
18
    </pdx:content>
19
</pdx:document>
20

settings.xml

12
 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<pdx:document  xmlns:pdx="http://www.phpdocx.com/main">
3
    <pdx:settings>
4
        <pdx:addPageBorders>
5
            <pdx:top pdx:color="FF0000" pdx:width="12" />
6
            <pdx:right pdx:width="12" />
7
            <pdx:bottom pdx:width="12" />
8
            <pdx:left pdx:width="12" />
9
        </pdx:addPageBorders>
10
    </pdx:settings>
11
</pdx:document>
12
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

The resulting Word document looks like: