tags:

views:

14

answers:

2

While attempting to find a way to merge existing PDF files and forms, I came across Sid Steward's PDFTK (http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/) and then found Andrew Heiss' PDFTK-php Class (code.google.com/p/pdftk-php/; www.andrewheiss.com/blog/2009/07/29/installing-pdftk-php/). The idea seemed so simple, but when I tried it on my Windows 2003 Server and on my Windows XP virtual PC I get the same error trying to fill_form using a FDF generated form Andrew's example code. I went ahead and changed Andrew's code around to see what the command line it was running. Then typed this into a command prompt window to see the error.

The command line looks like this: pdftk example.pdf fill_form fdf1b44.tmp output test.pdf flatten (PDFTK is in my System PATH and all the other files are located in the current directory) The example.pdf is generated as a 0KB file and an error pops up of:

Unhandled Java Exception:

java.io.CharConversionException at 0x0056175e (Unknown Source) at 0x00561c52 (Unknown Source) at 0x00561d03 (Unknown Source) at 0x0057692d (Unknown Source) at 0x0055f64d (Unknown Source) at 0x006bc0ad (Unknown Source) at 0x006994e0 (Unknown Source) at 0x00567a96 (Unknown Source) at 0x0056e8f2 (Unknown Source) at 0x0056e92c (Unknown Source) at 0x00445fa6 (Unknown Source) at 0x0048b15e (Unknown Source) at 0x0048b5b8 (Unknown Source) at 0x0048c238 (Unknown Source) at 0x0046c81f (Unknown Source) at 0x00469301 (Unknown Source)

at 0x004666a6 (Unknown Source)

The results are identical for the Windows XP virtual pc and the Windows 2003 Server. I've found very little on this issue and only possibly an entry that states Sid used a version of gcc to compile pdftk which had some poor java character support. I downloaded Sid's Source files to take a look, but it truely is beyond my scope of knowledge.

A: 

Found the answer on Andrew's site by Adam De Fouw. Apparently the copy of PDFTK-PHP out there for download has a corrupt version of the example.pdf file. So I wasn't the only one smacking my forehead trying to figure it out. See Adam's answer(http://www.andrewheiss.com/blog/2009/07/29/installing-pdftk-php/) below:

Adam De Fouw 05/10/2010 10:24 PM in reply to Josh

http://pdftk-php.andrewheiss.com/example/exampl...

Use this example.pdf on Andrew's site instead of the version on GitHub. I was pulling my hair out for the past 2 hours trying to figure out why it wasn't working. Turned out that embedded Mac fonts were my nemesis, as Andrew alluded to.

Use that PDF, and it should work for you.

Arachnid
A: 

Thanks Arachnid, you made my day. Your solution worked perfectly for me on my Windows XP test environment. Here is the full link to the example.pdf, clickable:

http://pdftk-php.andrewheiss.com/example/example.pdf

I added this as an issue to the pdftk-php github page, too.

Martin Terber Webman