I’ve reviewed some of the samples that use the PDFStamper, AcroFields, etc. objects to programmatically update fields from a PDF template and stream the update to a new PDF. The samples work great. However, when I tried the same things against a PDF template I created using Adobe Designer, the fields could not be referenced by name as done in the samples.  It appears that the fields are embedded in a tree (I assume the Cos Layer).  A debug statement after instantiating the PDFStamper shows fields as follows:

 

Fields info: [EMAIL PROTECTED], [EMAIL PROTECTED], etc…

 

Code Excerpt:

 

      PdfReader reader = new PdfReader("TestTemplate.pdf");

      PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("TestOut.pdf"));

      AcroFields form1 = stamper.getAcroFields();

      System.out.println("Fields info: "+form1.getFields().toString());

//    writer = PdfWriter.getInstance(document,new FileOutputStream("bidNotice"+bidNotice.getBidNoticeId()+".pdf"));

      form1.setField("field1","Test1");

      form1.setField("field2", "Test2");

      stamper.close();

 

Again, sorry for the newbie kind-of-question; in reviewing the template used in the sample vs the template I created, my template certainly has more involved in terms of tables. Embedded form fields, etc.  Is there another object(s) of iText I should use to traverse the document tree to get to the field nodes?  The sample template PDF was “hierarchy flat” so the references to a specific field didn’t involve subforms, etc.

 

TIA for any info.

 

Regards.

 

Reply via email to