Hi,
I’m using aspose-pdf-9.7.1-jdk16.jar.
I’ve used this code just to get started:
InputStream is = App.class.getResourceAsStream(“EP.pdf”);
Document doc = new Document(is);
if(doc != null){
System.out.println(“it’ loaded success”);
}
PageCollection pc = doc.getPages();
System.out.println(“This document has: " + pc.size() +” pages ");
Form form = doc.getForm();
Field[] fields = form.getFields();
System.out.println("Number of form fields: "+ fields.length);
the output is:
it’ loaded success
This document has: 1 pages
Number of form fields: 0
The problem is that the document has 26 and at least one form.
Could you please help me load the document in the right way, just to get me started.
Thank you,
Ivan
Hi Ivan,
Thanks for your inquiry. I have noticed the Aspose.Pdf for Java JAR is returning incorrect count of pages. So we have logged a ticket PDFNEWJAVA-34715 in our issue tracking system for further investigation and resolution. We will keep you updated about the issue resolution progress.
Moreover, to read Form fields from attached document. Your shared document is dynamic form so you can get form fields as following.
Document pdf = new Document(myDir + “EP.pdf”);<o:p></o:p>
String[] fields = pdf.getForm().get_xfa().getFieldNames();
for (int i = 0; i < fields.length; i++) {
System.out.println("XFA form field: " + fields[i]);
}
Best Regards,