Filling PDF form with PDFTK (or php/javabridge) ignoring certain unicode chars
Asked Answered
M

1

6

Possibly related question 1, Related question 2

What We're trying to accomplish:
Use drupal webform submition data as a source to fill a PDF form and serve it to the user, flattened for printing. We're trying to deploy this on Drupal 6 and later on Drupal 7. Site is a large D6 site deployed on a CentOS VPS. We're in the process of moving it to D7.

Links:

Our problem:
No matter what we try we can not get certain Unicode(utf-8) chars to be inserted into the PDF.
Specifically these do not work: č, đ, ć
These work: š, ž
NOTE: This has to work as these chars are common in names and surnames of Slovenians, and this pdf is a printout for a contract in Slovenia.

What we tried:
We first used PDFTK that our sysadmin built from source. We tried 1.41 and 1.41. He than found a package of both version and we tested them both. None worked. We than analyzed the module and used the same command line function with a striped down example. It produced the same result. We tried PDF generated on a Mac that was converted from a DOC, than fields added with Adobe Acrobat Pro. Than we tried a PDF created with LibreOffice on Linux Mint. Both produced the same results. This problem has been replicated on CentOS vps, CentOS virtualbox install of our sysadmin and a ubuntu 10.04 devbox and across 2 D6 vanilla installs, 1 D7 vanilla install and on the production D6 install. We also tried the second option given by the fillpdf module: java/tomcat bridge (More here). This was tried on the ubuntu 10.04 devbox and it also did not work. We also tried the provided software-as-a-service PDFTK service FillPDF service and it also produced the same result.

Any ideas what could be wrong? Any ideas how to get this done (even with the use of other system, services, custom code etc.)?

Maxa answered 5/1, 2012 at 11:57 Comment(4)
Putr, when you say that the Tomcat setup "did not work" did you mean you had trouble configuring it or that it filled PDFs but did not successfully fill those characters?Kovno
This answer seems to be a big hint: https://mcmap.net/q/947140/-flatten-fdf-xfdf-forms-to-pdf-in-php-with-utf-8-characters - seems like HTML-encoding the characters with Unicode character references is the way to go in the XFDF file. I'll make a note of this in the module and come back to take a look at it later. It's tricky because it seems like that'd work with pdftk, but not sure how it would come into play on the JavaBridge side.Kovno
@Kovno Tomcat setup worked (as far as PDF generation goes), but we still had the same problem with unicode chars.Maxa
Seems like it's a Tomcat/Java font issue. A Chinese user managed to add Chinese fonts somehow and get the whole thing working. I will read what he did more closely at some point and update the documentation (and do more testing).Kovno
N
1

Try using: http://sourceforge.net/projects/pdfformfiller2/files/.

For instalation do this:

Fillpdf:

drush dl fillpdf
drush en fillpdf

Webform:

drush dl webform
drush en webform

Webform tokens:

drush dl webform_tokens
drush en webform_tokens

PDF form filler 2:

itext-xtra-5.2.0.jar 0060b17c2ca9ee33a39806a8bad461e2

itextpdf-5.2.0.jar   ea0173384c42986e269da4fb67d0a391

pdfformfiller.jar    9109ecb8f887ea40719480134ed73ddd

pdf_filler.sh

You will also need this java packages on server:

giflib-4.1.3-7.3.3.el5.i386.rpm

java-1.6.0-openjdk-1.6.0.0-1.27.1.10.8.el5_8.i386.rpm

tzdata-java-2012c-1.el5.i386.rpm

chmod +x pdf_filler.sh

pdf_filler.sh should be in $PATH
Nebulose answered 13/11, 2014 at 9:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.