[
https://issues.apache.org/jira/browse/PDFBOX-3638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15764450#comment-15764450
]
ASF subversion and git services commented on PDFBOX-3638:
---------------------------------------------------------
Commit 1775307 from [~tilman] in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1775307 ]
PDFBOX-3638: return null if color array hasn't 1, 3 or 4 elements
> NullPointerException when setting form field value
> --------------------------------------------------
>
> Key: PDFBOX-3638
> URL: https://issues.apache.org/jira/browse/PDFBOX-3638
> Project: PDFBox
> Issue Type: Bug
> Components: AcroForm
> Affects Versions: 2.0.3, 2.0.4
> Reporter: Tilman Ginzel
> Attachments: input.pdf, pdfdebugger.png
>
>
> Hi,
> I am not able to fill out form fields using 2.0.3 or 2.0.4.
> When calling {{field.setValue("value")}} I get a NullPointerException.
> Code:
> {code}
> PDDocument doc = PDDocument.load(new File("input.pdf"));
> PDAcroForm form = doc.getDocumentCatalog().getAcroForm();
> form.getField("firstname").setValue("name");
> form.flatten();
> doc.save("output.pdf");
> {code}
> Stacktrace:
> {code}
> Exception in thread "main" java.lang.NullPointerException
> at
> org.apache.pdfbox.pdmodel.PDPageContentStream.getName(PDPageContentStream.java:964)
> at
> org.apache.pdfbox.pdmodel.PDPageContentStream.setNonStrokingColor(PDPageContentStream.java:1172)
> at
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.initializeAppearanceContent(AppearanceGeneratorHelper.java:211)
> 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)
> {code}
> The private property {{PDResources resources}} is null.
> If I set {{form.setNeedAppearances(true);}} before setting the value, the
> NullPointerException is gone. But then {{form.flatten()}} does break
> something, all form fields are empty in the resulting pdf.
> Maybe this is an issue with our pdf. The same code works using version 2.0.2,
> but there I suffer from the black border issue (see
> [3454|https://issues.apache.org/jira/browse/PDFBOX-3454])
> I attached the pdf and a screenshot with some infos from the PDFDebugger tool
> as requested.
> Thanks in advance.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]