- 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:searchAndHighlight
Searches for keywords within a Word document and highlights them.
This element allows the highlighting of plain text in a DOCX document.
src
The path to the source Word document.
target
The path to the Word document resulting after the text highlighting.
searchTerm
The string of text that we want to highlight.
options
The possible keys and values are:
key | Description |
---|---|
highlightColor | the color used for the highlighting:
The default value is ‘yellow’. |
document | If true highlights the search string in the body of the document. The default value is true. |
endnotes | If true highlights the search string in the document endnotes. The default value is false. |
comments | If true highlights the search string in the document comments. The default value is false. |
headersAndFooters | If true highlights the search string in headers and footers. The default value is true. |
footnotes | If true highlights the search string in the document footnotes. The default value is false. |
config.xml
content.xml
<pdx:document xmlns:pdx="http://www.phpdocx.com/main">
<pdx:utilities>
<pdx:searchAndHighlight pdx:source="/var/www/xmldocx/samples/files/second.docx" pdx:target="/var/www/xmldocx/samples/DocxUtilities/searchAndHighlight/output_searchAndHighlight.docx" pdx:searchTerm="data" pdx:highlightColor="green">
<pdx:valueContext pdx:value="document" />
<pdx:valueContext pdx:value="endnotes" />
<pdx:valueContext pdx:value="comments" />
<pdx:valueContext pdx:value="headersAndFooters" />
<pdx:valueContext pdx:value="footnotes" />
</pdx:searchAndHighlight>
</pdx:utilities>
</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()