- addBackgroundImage
- addFooter
- addHeader
- addLineNumbering
- addMacroFromDoc
- addPageBorders
- addProperties
- addSection
- createCharacterStyle
- createListStyle
- createParagraphStyle
- docxSettings
- importHeadersAndFooters
- importListStyle
- importStyles
- modifyPageLayout
- parseStyles
- removeFooters
- removeHeaders
- setBackgroundColor
- setDefaultFont
- setDocumentDefaultStyles
- setEncodeUTF8
- setLanguage
- setMarkAsFinal
pdx:removeChapter
Removes a whole chapter from a Word document.
Description
This element allows to remove (sub)chapters which corresponding heading contains a certain string of text.
This element finds all headings with the required string of text and removes all contents until one hits a new heading of the same or lower level.
Attributes and sub-elements
src
The path to the source Word document.
target
The path to the resulting Word document.
searchTerm
The string of text that we want to search in the headings.
Code samples
#Example 1
config.xml
content.xml
7
1
2
<pdx:document xmlns:pdx="http://www.phpdocx.com/main">
3
<pdx:utilities>
4
<pdx:removeChapter pdx:source="/var/www/xmldocx/samples/files/headings.docx" pdx:target="/var/www/xmldocx/samples/DocxUtilities/removeChapter/output_removeChapter.docx" pdx:searchTerm="First Heading" />
5
</pdx:utilities>
6
</pdx:document>
7
settings.xml
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