我正在自动创建一个msword文档。当它完成后,我需要能够将它保存为PDF,并在Word文档的PDF版本中插入一些其他/外部PDF页面。为此,我计划在Word文档中留下标记(例如“[pdfgoesher]”)在自己的页面上。在
要插入/替换新的PDF页面,我需要知道标记在哪些页面上。PythonDocx有办法确定一个段落开始(和结束)的页码吗?我已经通读了python-docx documentation,但似乎没有任何与此相关的内容。我知道我可以循环浏览所有段落并找到我感兴趣的段落,但我找不到确定的方法来获取段落的页码。在
有没有我忽略的方法?如果没有,对于如何完成插入PDF页面的主要目标,还有其他建议吗?在
感谢@scanny的反馈。因为在
python-docx
中没有办法做到这一点,而且我还是要把文档转换成PDF格式,所以我决定在Word文档转换成PDF之后使用pdfminer
来获取页码。这段代码可能很长,但它可以完成任务在此之后,
PyPDF2
可用于简单的PDF页面插入/合并简单的回答是否定的。页码是在呈现时确定的,并且由于可用字体等因素而依赖于设备。在
这个答案有更多的细节: Page number python-docx
相关问题 更多 >
编程相关推荐