Question:

I need a Linux-based script to replace text in a PDF document on the fly?

by  |  earlier

0 LIKES UnLike

I would like to serve customized PDF documents from templates. The templates contain tokens like {firstname} that would be replaced with actual data.

Unfortunately, internal compression in the PDF makes it impossible to write a simple search/replace Perl script. What toolkit or existing script would allow me to do this on a Linux web server?

 Tags:

   Report

2 ANSWERS


  1. This may not be the answer that you are looking for but you could keep your templates in postscript format and perform the search & replace on those files.  Then, you could use ps2pdf to convert the postscript file to PDF format for delivery.


  2. Hmmm... that is tricky. I'm guessing that if you could properly decompress it to a file, you could run a sed substitution that would (hopefully) replace what you need. There is a tiny chance that it would s***w up an image or other element, but you could try it. The only hard part would be decompressing it, and I have no idea how you could do that. There must be some sort of PDF library that is used in open source PDF readers and web browsers.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.