pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Meissner <r.meiss...@applicationpark.de>
Subject Adding a hidden PDField to a PDAcroForm
Date Mon, 11 May 2015 09:43:22 GMT
Hello,

I need to add a new hidden fields to a PDAcroForm. How can i do this?
I already created the following code, that changes the values of 
existing fields, but i need to create new fields and add the to the 
PDAcroForm. The fields should be hidden.

document = PDDocument.load(req.getInputStream());
final PDPage page = (PDPage) 
document.getDocumentCatalog().getAllPages().get(document.getNumberOfPages() 
- 1);
final PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm();
for (final PDField field : (List<PDField>) acroForm.getFields()) {
     switch (field.getFullyQualifiedName()) {
         case "myField": {
             field.setValue("newValue");
             break;
         }
         default:
     }
}
document.save("Z:/1.pdf");
document.close();

Thanks for your reply in advance!

Best regards,
RoMe

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message