简体   繁体   English

如何使用Python向现有的PDF文件添加文本

[英]How to add text to existing PDF file with Python

I am looking for a Python module and some examples on how to add Text to an existing PDF. 我正在寻找一个Python模块以及一些有关如何将文本添加到现有PDF的示例。 The PDF file is an one page PDF and I would need to add the info at a predetermined position. PDF文件是一页PDF,我需要在预定位置添加信息。 The text can be added as part of the document or as a comment. 可以将文本添加为​​文档的一部分或注释。 I would also need to read the comments that are in this document. 我还需要阅读本文档中的评论。

What is the best Python module that I can use for this? 我可以为此使用的最佳Python模块是什么? The environment is Windows 7 and Python 2.7 x64. 环境是Windows 7和Python 2.7 x64。

I have tried to compile poppler but it is a nightmare The other libraries that I have looked at are pyPDF2 and PDF1.0 but I could not locate the objects and the methods that I need to use to achieve my task. 我试图编译poppler,但这是一场噩梦。我看过的其他库是pyPDF2和PDF1.0,但是我无法找到实现任务所需的对象和方法。 My level is "beginner" so please if I overlooked anything is because of this. 我的水平是“初学者”,所以如果我忽略了任何事情,则请这样做。

This question has been asked, and was very thoroughly answered. 有人问过这个问题,回答得很彻底。 Check it out here! 在这里查看! The first answer is nicely general, and walks you through each step of the process. 第一个答案很笼统,将引导您完成流程的每个步骤。 The second answer is instead straight code that you can run. 第二个答案是可以运行的直接代码。 Both are valuable and well-written; 两者都是有价值的且写得很好; choose whichever works best for you. 选择最适合您的。 (Or both!) (或两者!)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM