2

I was wondering if it's possible to édit an existing pdf file with Pdfminer. It seens to be a powerful tool, but the documentation is poor/inexisting. I found some exemples, but they don't match with my goal. I want to make a search engine which changes the color of my keywords in the pdf file.

2 Answers 2

0

PDFMiner is not for altering existing PDF files, but for extracting text and metadata from them. The closest solution to what you're looking for using PDFMiner would probably be to use the included pdf2txt.py tool to extract the text and then mark that up to highlight your keywords.

There's also the simple option of just using a PDF viewer with the built-in ability to find and highlight multiple search terms. I think Adobe Acrobat can do it, but I'm not sure about others.

0

No, pdfminer doesn't support editing.

However, it might be a lot easier if you don't try to modify the pdf, but use PDFOpenParameters instead: http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf

You can use url fragment identifiers like this:

http://www.example.com/test.pdf#search=foo

Or even when opening Acrobat on the commandline (Windows example)

AcroRd32.exe /A "search=foo" test.pdf

You could also open the pdf a specific page, and highlight a certain area of that page (but not different areas on different pages at the same time).

(ok, I know it's not really a solution for the question you asked, but if this is sufficient for your needs, it's a lot simpler)

1
  • Cool, I'm getting closer to the solution. Thanks! Nov 29, 2011 at 20:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.