views:

862

answers:

2

Does anyone know of a free Perl program (command line preferable), module, or anyway to search and replace text in a PDF file without using it like an editor.

Basically I want to write a program (in Perl preferably) to automate replacing certain words (e.g. our old address) in a few hundred PDF files. I could use any program that supports command line arguments. I know there are many modules on CPAN that manipulate or create pdfs but they don't have (that I've seen) any sort of simple search and replace.

Thanks in advance for any and all advice!!!

A: 

How did you generate those PDFs in the first place? Search-and-replace in the original sources and re-generate PDFs seems to be more viable. Direct editing PDFs can be very difficult, and I'm not aware of any free tools that can do it easily.

PolyThinker
+3  A: 

Take a look at CAM::PDF. More specifically the changeString method.

Mr. Muskrat
I'm the CAM::PDF author. Note that searching for text in PDF is inherently hard because of the graphical nature of the document, so you'll probably need to assume a trial-and-error approach.
Chris Dolan
Chris, that is a very good point that the OP probably hadn't thought about.
Mr. Muskrat