[
https://issues.apache.org/jira/browse/PDFBOX-2755?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14491103#comment-14491103
]
Maruan Sahyoun commented on PDFBOX-2755:
----------------------------------------
The reason why this happens is because you set the field value for the AcroForm
field. And this is correctly handled. But opening the form with Adobe Reader
the XFA content will be interpreted and there the field
DCSS_0373_APPLICANT_NAME is defined as a global field meaning that the data
will be read from the XML within xfa:datasets:data. There the data is empty and
as a result - although you set the data value for the AcroForm field - that
will be overwritten by the empty value in the XML.
You have two options:
a) set the data value in the XML
b) remove the XFA content prior to saving the document.
{code}
PDAcroForm form = doc.getDocumentCatalog().getAcroForm();
form.getDictionary().removeItem(COSName.getPDFName("XFA"));
{code}
Btw. opening the filled out form e.g. in OS X Preview - which will ignore the
XFA content - the new data value will be visible.
> Can't save the change to pdf file
> ---------------------------------
>
> Key: PDFBOX-2755
> URL: https://issues.apache.org/jira/browse/PDFBOX-2755
> Project: PDFBox
> Issue Type: Bug
> Components: AcroForm
> Affects Versions: 1.8.9
> Reporter: hui xu
> Priority: Critical
> Attachments: formtestFailed.pdf, formtestOK.pdf
>
>
> Ran SetField.java in package org.apache.pdfbox.examples.fdf, the field value
> is changed but can not been saved in pdf file.
> I added 2 more lines code:
> List<PDField> newList = new ArrayList<PDField>();
> .................................
> acroForm.setFields(newList);
> The pdf was saved with the change. But reload the saved pdf file and try to
> reset some values, it throws NullPointerException, the file can't getFields().
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]