开发者

Using Sid Steward's PDFTK in Windows receiving a Unhandled Java Exception: java.io.CharConversionException

While attempting to find a way to merge existing PDF files and forms, I came across Sid Steward's PDFTK 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 0x开发者_如何学JAVA00469301 (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.


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.


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.


I was encountering the same error using PDFtk and my own PHP code (not pdftk-php) to do an FDF/PDF merge. I spent two days trying to figure it out. I modified my code to merge the fields one by one and report back with the specific fields that caused the error--as some of them worked fine and others didn't. Upon inspecting the diffs between the fields that caused errors and the fields that didn't, I realized the fields that caused errors were set to OpenSans font. The fields that worked were set to Times Roman. Once I changed all fields to use Times Roman instead of OpenSans, PDFtk quit throwing the error. I hope my two days of head banging helps someone someday.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜