Save Open XML as PDF

The nice thing about the Office OpenXML is that it’s the language of Microsoft Office — if you live your “office life” in Word and Excel (2007 and later), that’s the format you want. Can you “save” OpenXML directly to PDF? No, it needs to be rendered by some third-party component. If you’re doing document … Read more

Replace image in word doc using OpenXML

Although the documentation for OpenXML isn’t great, there is an excellent tool that you can use to see how existing Word documents are built. If you install the OpenXml SDK it comes with the DocumentReflector.exe tool under the Open XML Format SDK\V2.0\tools directory. Images in Word documents consist of the image data and an ID … Read more

Create page break using OpenXml

You can create a page break within a Run element using the <w:br> element. In raw OpenXML, it would look something like: <w:p> <w:r> <w:br w:type=”page” /> </w:r> </w:p> If you’re using the OpenXml SDK, you can use new Paragraph( new Run( new Break(){ Type = BreakValues.Page })); EDIT: If you just want to specify … Read more

How can I search a word in a Word 2007 .docx file?

After reading your post above, I made a 100% native Python docx module to solve this specific problem. # Import the module from docx import document, opendocx # Open the .docx file document = opendocx(‘A document.docx’) # Search returns true if found search(document,’your search string’) The docx module is at https://python-docx.readthedocs.org/en/latest/