in reply to Editing/Replacing Text in a PDF

The PDF contains various checksums that make it difficult to replace text this way, unless you use code that recomputes the checksum and puts them into the PDF. It also positions the text based on the width, so you might have best luck with center justified text, for example.

In general, it is also possible that the PDF contains compressed text.

You also forgot binmode on the OUT file handle.

The crude way to do what you want is to convert the PDF to Postscript, substitute the text, and convert it back. I use the ImageMagick program 'convert' to do this.

`convert Build3.pdf Build3.ps` ... Postscript filtering code goes here ... `convert Build3.ps out.pdf`
There are also perl modules available to wrap the ImageMagick functionality. I believe that ImageMagick is in turn calling Ghostscript to handle the conversion, so you could use that directly, instead.

It should work perfectly the first time! - toma

Replies are listed 'Best First'.
Re^2: Editing/Replacing Text in a PDF
by ikkon (Monk) on Dec 20, 2006 at 16:26 UTC
    thanks, this is very usefull info i will check this out and let you know what i figure out, thanks again.