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 field to a pDF
Date Mon, 11 May 2015 09:30:17 GMT
Hello,

I need to add 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()) {
                         PDFieldFactory.createField(acroForm, arg1)
                         switch (field.getFullyQualifiedName()) {
                             case "partnerPk": {
                                 field.setValue("7");
                                 break;
                             }
                             case "glaeubigerPk": {
                                 field.setValue("1");
                                 break;
                             }
                             case "aktePk": {
                                 field.setValue("3");
                                 break;
                             }
                             case "dokumentPk": {
                                 field.setValue("7");
                                 break;
                             }
                             case "partnerId": {
                                 field.setValue("070");
                                 break;
                             }
                             case "glaeubigerId": {
                                 field.setValue("11501");
                                 break;
                             }
                             case "partnerKey": {
                                 field.setValue("BOB");
                                 field.setReadonly(true);
                                 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