2

I am looking for a Python module and some examples on how to add Text to an existing PDF. The PDF file is an one page PDF and I would need to add the info at a predetermined position. 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? The environment is Windows 7 and 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. My level is "beginner" so please if I overlooked anything is because of this.

5
  • 2
    Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. Commented Apr 13, 2015 at 20:05
  • 1
    Please feel free to suggest how I should rephrase my question and I will do it. How can I be specific when I do not know which library can do this. I already indicated what I have looked at and what I already tried (ex poppler which has to be compiled using make which could not find the .h files, after I solved that I run into a .lib problem and that only to install a sip module that was a pre requirement to install poppler) Commented Apr 13, 2015 at 20:34
  • The point is that you can't rephrase that question to be specific, and thus this question is off-topic for stackOverflow, hence my copy&paste of the official off-topic rules. Commented Apr 14, 2015 at 10:35
  • I think by comments you most likely mean annotations. Try searching on that, e.g. stackoverflow.com/questions/1106098/… Commented Apr 14, 2015 at 20:33
  • I tried that and I did not get much. I ended up using cpdf , a CLI utility that dumped the comments to stdout and I captured the output of that command. Further I used reportlab to create a new pdf page with the text that I wanted to add and I merged that with the existing doc. I could not find a python solution for reading comments that would work on Windows. Poppler is very difficult to configure Commented Apr 15, 2015 at 0:24

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

4 Comments

Yes I came accross that example but it looked to me that the library is an overkill since I do not want to create graphs and reports, I needed something simpler That example does now explain how to read the existing comments from my document (I need to read them and to add text based on what I it is int the document. I am now trying to install this library (ReportLab) but please point me to an example on how to read comments with this library. If it can not do this it is pointless because the comments that I add are based on processing the existing comments
Hi Greg, you shouldn't do "has already been answered here" answers -- flag the question as duplicate, instead.
I would be glad to read the duplicate where it is explained how to read the comments added to a PDF file without using poppler
Thanks Marcus, my mistake. I appreciate your constructive feedback :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.