- 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:replaceVariableByWordML
Replaces placeholder variables by plain WordML code.
Element definition
<pdx:templateVariables pdx:preprocessedTemplate="">
<pdx:replaceVariableByWordML pdx:type="inline|block" pdx:target="" pdx:firstMatch="">
<pdx:variable pdx:name="">
<pdx:data pdx:dataId="" pdx:dataType="text"><![CDATA[WordML code]]></pdx:data>
</pdx:variable>
<pdx:variable pdx:name="">
<pdx:data pdx:dataId="" pdx:dataType="text"><![CDATA[WordML code]]></pdx:data>
</pdx:variable>
</pdx:replaceVariableByWordML>
</pdx:templateVariables>
This element (avalaible for the seasoned xmldocx user) allows the direct substitution of placeholder variables by WordML code.
Only use this element if you really understand the OOXML standard. xmldocx does not validate the WordML against any scheme so you have to make sure by your own that the WordML is correctly encoded. Moreover, this element does not take care by its own of internal/external relationships included in the WordML code.
variable
The names of the placeholder template variables and the WordFragment instances that should replace them as values.
options
key | Description |
---|---|
firstMatch | If the variable appears more than once within the Word document and firstMatch is set to true, xmldocx will only replace the first ocurrence of the variable within the Word document. |
target | Possible values are: document. This option sets the scope of the replacement procedure. |
replaceType | Possible values are:
|
config.xml
content.xml
<pdx:document xmlns:pdx="http://www.phpdocx.com/main">
<pdx:templateVariables pdx:preprocessedTemplate="">
<pdx:replaceVariableByWordML>
<pdx:variable pdx:name="WORDML">
<pdx:data pdx:dataId="" pdx:dataType="text">
<![CDATA[<w:p><w:r><w:t xml:space="preserve">This is a simple paragraph with some </w:t></w:r><w:r><w:rPr><w:b/></w:rPr><w:t>bold</w:t></w:r><w:r><w:t xml:space="preserve"> text.</w:t></w:r></w:p>]]>
</pdx:data>
</pdx:variable>
</pdx:replaceVariableByWordML>
</pdx:templateVariables>
</pdx:document>
settings.xml
import os as os
import sys as sys
sys.path.append(os.path.abspath("wrappers/python/XmlDocx"))
import XmlDocx as XmlDocx
document = XmlDocx.XmlDocx("config.xml")
document.setDocumentProperties("settings.xml")
document.addContent("content.xml")
document.setXmlDocxPath("xmldocx path")
document.render()