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.

MiniMe
  • 1,057
  • 4
  • 22
  • 47
  • 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. – Marcus Müller Apr 13 '15 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) – MiniMe Apr 13 '15 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. – Marcus Müller Apr 14 '15 at 10:35
  • I think by `comments` you most likely mean `annotations`. Try searching on that, e.g. http://stackoverflow.com/questions/1106098/parse-annotations-from-a-pdf – dwarring Apr 14 '15 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 – MiniMe Apr 15 '15 at 00:24

1 Answers1

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

Community
  • 1
  • 1
Greg Edelston
  • 534
  • 2
  • 12
  • 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 – MiniMe Apr 13 '15 at 20:31
  • 1
    Hi Greg, you shouldn't do "has already been answered here" answers -- flag the question as duplicate, instead. – Marcus Müller Apr 14 '15 at 10:34
  • 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 – MiniMe Apr 14 '15 at 13:05
  • Thanks Marcus, my mistake. I appreciate your constructive feedback :) – Greg Edelston Apr 14 '15 at 19:28