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 easy search/replace Perl script. What toolkit or existing script would grant me to do this on a Linux web server?
I tried saving to Postscript, editing the text within the PostScript file then reopening the document. The changed text was garbled. So, there is other metric information within the file that is no longer accurate once the text is changed.

I am looking at the CAM-PDF module that claims it can do a search and replace on text in a PDF doc but it has dependencies on other modules that have their own dependencies. It is a nightmare to try and install. Still trying.
FINAL UPDATE: I installed the CAM::PDF library from CPAN and it got the job done. Most importantly, I had to use a trick to ensure all the letters of all the fonts were in the PDF document.

I created a first page including the entire alphabet and character set for each font used in the document. That way, all the letters would be encapsulated for later use when I started substituting letters. So, with CAM::PDF, I did a text replacement then I removed the first page that contained the font alphabets. The commands I used are:

changepagestring.pl 1973_2pg.pdf “{YourName}” “Roger Smith” 1973m.pdf

deletepdfpage.pl 1973m.pdf 1 1973_final.pdf

The installation process for CPAN is lengthy and requires root access on the Linux server.