I have a docx file with just text. I would like to create a new docx file containing just part of a page in the original docx. I am using python-docx for this. So far I have been able to transverse the original docx document and copy each desired paragraph/run in the original to the new document as follows (this example should make an exact copy, I believe):
Doc = docx.Document('/tmp/input.docx')
OutDoc = docx.Document()
for para in Doc.paragraphs:
currentParagraph = OutDoc.add_paragraph(style=para.style)
for run in para.runs:
currentParagraph.add_run(run.text, style=run.style)
OutDoc.save('/tmp/output.docx')
Even though I am copying all style information, it seems that I am missing something, as the output lacks some of the formatting.