I am having an issue with trying to set some from fields using Apache PDFBOX(1.8.5). I have a few different Static PDFs that I am using for testing. Using the following code, I can set the values of form fields, and save the resulting PDF. I can then open this PDF in Adobe Reader and see the results:
PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
pdfTemplate.setAllSecurityToBeRemoved(true);
PDAcroForm acroForm = docCatalog.getAcroForm();
List fields = acroForm.getFields();
Iterator fieldsIter = fields.iterator();
while( fieldsIter.hasNext())
{
PDField field = (PDField)fieldsIter.next();
if(field instanceof PDTextbox){
((PDTextbox)field).setValue("STATIC PDFBOX EDIT");
}
}
And then I eventually save the form. For Static PDFs of:
- PDF Version: 1.6 (Acrobat 7.x)
- PDF Version: 1.7 (Acrobat 8.x)
This works just fine. I can open the Documents in Adobe Reader XI and see the correct values in the form.
For Static PDFs of:
- PDF Version: 1.7 Adobe Extension Level 3(Acrobat 9.x)
- PDF Version: 1.7 Adobe Extension Level 8(Acrobat X)
- PDF Version: 1.7 Adobe Extension Level 11(Acrobat XI)
This appears to not be working. When I open the resulting forms in Adobe Reader XI, the fields do not appear to be populated. But If I open the PDF in my Firefox or Chrome browser's PDF viewer, the fields show as populated there.
How can I set these fields so the values will appear when viewed in Adobe Reader XI?
EDIT: Sample PDFs can be found here: https://github.com/bamundson/PDFExample