You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2016/12/20 15:03:58 UTC

[jira] [Commented] (PDFBOX-3638) NullPointerException when setting form field value

    [ https://issues.apache.org/jira/browse/PDFBOX-3638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15764392#comment-15764392 ] 

ASF subversion and git services commented on PDFBOX-3638:
---------------------------------------------------------

Commit 1775301 from [~tilman] in branch 'pdfbox/branches/2.0'
[ https://svn.apache.org/r1775301 ]

PDFBOX-3638: add resources dictionary

> 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: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org