pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Tanner <br...@fireplan.ca>
Subject Null Pointer Exceptions when trying to set field value
Date Sun, 08 Jan 2017 21:53:36 GMT
Hi all. I’m green as grass, so apologies in advance.

I am creating a PDF in the following way:
a) Creating various template files with placeholders in Adobe inDesign
b) Extendscript (Adobe scripting tools) used to put together templates, fill text values,
**create TextBox FormFields**, export as an Adobe Interactive PDF all through Indesign.

I’m working on a Mac.

Out pops a nice PDF that I can open and fill values in with either Preview.app or Acrobat
Pro.  In Acrobat, when go Tools->Prepare form, all my fields are there with their names
set correctly.

What I *want* is to pre-fill known values on these forms as part of this automated workflow.

Apparently it is impossible to  pre-fill/set default form field values from within inDesign.

Scripting control of Acrobat to load form field values from a text file is not trivial. Could
be done manually.

Google quickly helped me zero in on the PDFBox project, which seems awesome and will be useful
for various things I do. Hooray.

However, I’m having trouble right off the bat because with 2.04 I am getting a null pointer
exception when I try to set a form field value:

Exception in thread "main" java.lang.NullPointerException
	at org.apache.pdfbox.pdmodel.PDResources.add(PDResources.java:675)
	at org.apache.pdfbox.pdmodel.PDResources.add(PDResources.java:573)
	at org.apache.pdfbox.pdmodel.PDPageContentStream.getName(PDPageContentStream.java:964)
	at org.apache.pdfbox.pdmodel.PDPageContentStream.setStrokingColor(PDPageContentStream.java:979)
	at org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.initializeAppearanceContent(AppearanceGeneratorHelper.java:221)
	at org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceValue(AppearanceGeneratorHelper.java:167)
	at org.apache.pdfbox.pdmodel.interactive.form.PDTextField.constructAppearances(PDTextField.java:263)
	at org.apache.pdfbox.pdmodel.interactive.form.PDTerminalField.applyChange(PDTerminalField.java:228)
	at org.apache.pdfbox.pdmodel.interactive.form.PDTextField.setValue(PDTextField.java:218)
	at com.fireplan.pdf.PDFFillTester.main(PDFFillTester.java:55)

It seems like there is some form setup that I need to do either at the inDesign stage or with
PDFBox before I can fill my form fields. Anyone have any direction?

Here is a download link from one of the forms with the issue:
https://dl.dropboxusercontent.com/u/5922585/ContactForms-Fillable-2017-1-8_919.pdf <https://dl.dropboxusercontent.com/u/5922585/ContactForms-Fillable-2017-1-8_919.pdf>

If I export my document without form fields from indesign, then create them with indesign
using the automatic features, then the PDFBox code works.

So, obviously inDesign is not doing something with the interactive PDF setup that PDFBox needs/wants
that Acrobat does.  I just have no idea what.

Any help would be much appreciated.

--
Brian Tanner
Operations Manager, Fire Inspector
brian@fireplan.ca
204-975-4901 Extension 102

Fire Plan Strategies: Fire safety training, planning, signs, and supplies across Canada!


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message