how to know when a new paragraph in python-docx causes a new page

后端 未结 1 1694
生来不讨喜
生来不讨喜 2021-01-26 07:06

I have to create word documents dynamically using python-docx. I do it by adding table rows dynamically and there is no way to know how many records fit on a pa

相关标签:
1条回答
  • 2021-01-26 07:25

    Detecting automatic (renderer-generated) page breaks in python-docx is not possible because those breaks are not reliably recorded in the XML.

    You may be able to find some indication of the last rendered page break, depending on where your .docx files came from. Otherwise you probably need to use the Microsoft VBA interface to gain access to a live renderer which may be able to provide you this information. Note the page break location is subject to change based on the machine Word is running on, depending on factors like font metrics and printer drivers.

    This has come up in other questions and answers. This one might be a good place to start: Page number python-docx

    To see the rest, search on "[python-docx] page break" and you'll see there are quite a few. The square bracketed part limits results to those tagged with "python-docx".

    0 讨论(0)
提交回复
热议问题