Problem With Get Values from All Fields in a PDF Document Example

I am trying to extract data from an existing PDF Form and I am trying to use the posted example to understand how to extract all user supplied values from a PDF document/form. When I try to use the posted example code: (see * Get values for all Fields in a PDF Document.)

// Java
//
// Open document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(“input.pdf”);
com.aspose.pdf.Form form = pdfDocument.getForm();
IEnumerator fi = form.iterator();
while(fi.hasNext()) {
// Get the name of form field
System.out.println(((com.aspose.pdf.Field)fi.next()).getPartialName());
// Get the value associated with form field
System.out.println(((com.aspose.pdf.Field)fi.next()).getValue());
}// end while loop

I cannot determine the proper import for the IEnumerator object used to iterate through the “input.pdf”. It appears this is an outdated example because the only referrences to an IEnumerator object are found in the Aspose.Slides or Aspose.email.Collections libraries. Can someone either clarify which import should be used, or provide an updated sample?

Thanks.
Ed

Hi Edwin,


We are sorry for the inconvenience. We will look into the documentation code and will update it soon. Please check following code snippet to get values of form fields. Hopefully it will help you to accomplish the task.

Document pdf = new Document(myDir + “Form.pdf”);<o:p></o:p>

Field[] fields1 = pdf.getForm().getFields();

for (int i = 0; i < fields1.length; i++) {

System.out.println("Form field: " + fields1[i].getFullName());

System.out.println("Form field: " + fields1[i].getValue());

}


Please feel free to contact us for any further assistance.


Best Regards,

Hi Edwin,


In addition to above reply. We have updated the subjected documentation link with correct sample code snippet. Thanks for pointing out the issue.

Please feel free to contact us for any further assistance.

Best Regards,