I'm having difficulties filling in a form using pdftk
with text fields with true type fonts.
- Font files (.ttf) are added to /Library/Fonts (OSX Mavericks)
- The form is created with Adobe Acrobat Pro
- The form includes normal (non form) text using these fonts
- The form text fields also use these fonts
- The form can successfully be filled and printed using Adobe Acrobat Pro and even Preview
However, pdftk
throws an error when trying to fill it using the command:
pdftk ./my_form.pdf fill_form my_data.fdf output ./the_output.pdf
The output is:
Unhandled Java Exception in create_output():
java.lang.ArrayIndexOutOfBoundsException: 0
at pdftk.com.lowagie.text.pdf.DocumentFont.fillEncoding(pdftk)
at pdftk.com.lowagie.text.pdf.DocumentFont.doType1TT(pdftk)
at pdftk.com.lowagie.text.pdf.DocumentFont.<init>(pdftk)
at pdftk.com.lowagie.text.pdf.AcroFields.getAppearance(pdftk)
at pdftk.com.lowagie.text.pdf.AcroFields.setField(pdftk)
at pdftk.com.lowagie.text.pdf.AcroFields.setFields(pdftk)
If I change the font of the text inputs to Helvetica, Times Roman or Courier, pdftk
will successfully create a PDF. Oddly though, Arial and Georgia also throw the same error.
I have tried to no avail to embed the fonts in the PDF using Ghostscript as suggested in this question How to repair a PDF file and embed missing fonts. gs
may have embedded the fonts, but it removes the form fields so the resulting PDF can't feed back into pdftk
.
A working resolution would be greatly appreciated.
pdftk
is the only way for many people outside of the Java world. So your advise to use iText is simply not feasible for many of us. But how about providing a nice and clean command line tool with iText to make it available to a much broader audience? – Marchall