How to properly deviate from python-docx?
The indentation seems to be quite simple and the terminal prints the correct indentation, but the same indentation is not reflected in my saved Word docx. Am I doing something wrong here?
from docx import Document
from docx.shared import Inches
worddoc = Document()
paragraph = worddoc.add_paragraph('Left Indent Test')
paragraph.left_indent = Inches(.25)
print(paragraph.left_indent.inches)
worddoc.save('left_indent.docx')
source to share
This turns out to be a documentation error.
If you are using the new API, it works:
paragraph.paragraph_format.left_indent = Inches(0.25)
The property has left_indent
been moved to the sub-object paragraph_format
"pair is freed because the class is ParagraphFormat
used by objects Paragraph
and ParagraphStyle
."
If you submit a bug report to the issue tracker python-docx
on GitHub, we'll update the documentation next time we're there.
source to share