0

I am using itext to manipulate a existing pdf. To achieve so I need to first get the list of name of the fields. I use this code to get the list

PdfDocument pdfDoc = new PdfDocument(new PdfReader("tempPdf.pdf"), new PdfWriter("pdfEdited.pdf"));
PdfAcroForm acroForm = PdfAcroForm.getAcroForm(pdfDoc, false);
Map<String,PdfFormField> fields = acroForm.getFormFields();
for (String fldName : fields.keySet()) {
    System.out.println( fldName + ": --" + fields.get( fldName ).getValueAsString() );
}
pdfDoc.close();

The problem is I dont get the names of the fields instead get something like this which is not helpful. Is this becuase the pdf actually has these names for fields ?

pdfTemp[0].Page5[0].Table3[0].BodyRow2[0].f5_029[0]: --
pdfTemp[0].Page5[0].Table3[0].BodyRow2[0].f5_030[0]: --
pdfTemp[0].Page5[0].Table3[0].BodyRow2[0].f5_031[0]: --
pdfTemp[0].Page5[0].Table3[0].BodyRow2[0].f5_032[0]: --
ksernow
  • 662
  • 3
  • 14
  • 33
  • 1
    Possible duplicate of [How do I get all the fields and value from a PDF file using iText?](https://stackoverflow.com/questions/6056401/how-do-i-get-all-the-fields-and-value-from-a-pdf-file-using-itext) – Adam Jun 12 '17 at 16:35
  • 1
    *"The problem is I dont get the names of the fields instead get something like this which is not helpful."* - Why do you think those are not the names of the fields? To me that looks like the names of fields of a XFA or hybrid AcroForm/XFA form definition. – mkl Jun 12 '17 at 16:49

0 Answers0