2
我需要快速更改许多docx文档的边距。我检查了python-docx,并且找不到访问/修改页面布局(特别是边距)属性的方法。有没有办法?使用python-docx修改docx页边距
我需要快速更改许多docx文档的边距。我检查了python-docx,并且找不到访问/修改页面布局(特别是边距)属性的方法。有没有办法?使用python-docx修改docx页边距
感谢@tdelaney指出了明确指出解决方案的页面。 我只是张贴在这里的代码,我在任何情况下使用其他人的困惑,我当初是:
#Open the document
document = Document(args.inputFile)
#changing the page margins
sections = document.sections
for section in sections:
section.top_margin = Cm(margin)
section.bottom_margin = Cm(margin)
section.left_margin = Cm(margin)
section.right_margin = Cm(margin)
document.save(args.outputFile)
利润率由[Section对象(控制http://python-docx.readthedocs.org/en/最新/ API/section.html#段的对象)。有关更多详细信息,请参阅[使用节](http://python-docx.readthedocs.org/en/latest/user/sections.html)。我认为您可以列举文档中的部分并更改边距属性。 – tdelaney
完全正确@tdelaney,不知何故,我误解了这部分的文档。感谢您指出了这一点! – XAnguera