2015-06-01 187 views
3

缩进似乎非常简单,终端打印正确的缩进,但相同的缩进不会反映在我保存的Word docx中。我在这里做错了什么?如何正确缩进python-docx?

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') 

回答

2

原来是文档错误。

如果使用新的API工作原理:

paragraph.paragraph_format.left_indent = Inches(0.25) 

left_indent财产被转移到paragraph_format“子对象”几个版本早在ParagraphFormat类用于由ParagraphParagraphStyle对象都。

如果您将在GitHub上的python-docx问题跟踪器中提交错误报告,我们将在下次我们访问该文档时获取更新的文档。

+0

会做,谢谢! – j4w