Unable to Get fields count of a PDF form after populating it using Aspose.PDF for Java

I have a PDF form which have 23 fillable fields,
when i iterate thru all fields i get 23 count and i can see every field name and empty values of these fields, this works OK.

then I enter data by hand and save the file under a different name.
then load the form and try to iterate thru all fields to get the values and names… but I am getting always 0 for fields.lenght

Please help. (my environment, Win10, Eclipet 2019, aspose.total for java)
---------------------------my code ------------------------------------------------------------------------
static Field[] fields = null;

com.aspose.pdf.License license = new com.aspose.pdf.License();
try {
license.setLicense(“Aspose.Total.Java.lic”);
} catch (Exception e) {
e.printStackTrace();
}

	// Open a document
	String docIn = "C:\temp\myDoc.pdf";

	pdfDocument = new Document(docIn.trim());
	
	//Get All field of the input PDF document
	fields = pdfDocument.getForm().getFields();

   //Note: the code below never runs because fields.length is always zero
	for (int i = 0; i < fields.length; i++) {
		System.out.println("Form field: " + fields[i].getFullName()            + "\n" +
	                       "GetClass: " + fields[i].getClass().getTypeName()   + "\n" +
	                       "GetClass: " + fields[i].getClass().getSimpleName() + "\n" +
		                   "value: " + fields[i].getValue());
	}

Thank you very much in advance.
Marc

@mromero_rubinrothman_com

Thanks for contacting support.

Would you please share your PDF documents (both filled and with blank fields) with us. We will test the scenario in our environment and address it accordingly.

Hi Asad,

thank you for your fast response, you guys are the BEST!!

here are my PDF files:

FormMA4.pdf --> this is an new and empty PDF form (fillable)
when i loop thru this file fields array… everything works ok
i can see the field-names and the values are null which is ok because it is new.

FormMA4_data.pdf --> this is the same file which i populated by hand and entered data.
then saved under s different name.
when i loop thru this file fields array, the count = 0
and it does not work, it looks like it does not have fields anymore.

Thank you for your help.

FormMA4.pdf (154.8 KB)
FormMA4_data.pdf (135.4 KB)

@mromero_rubinrothman_com

Thanks for sharing sample files.

We have tested the scenario in our environment using Aspose.PDF for Java 19.5 and were able to reproduce the issue. Therefore, we have logged it as PDFJAVA-38639 in our issue tracking system for further investigation. We will surely look into details of the issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hi Asad,
Thank you for logging this issue# PDFJAVA-38639.
I just have one last question, in the future if you resolve this issue, how do i look for the result?

@mromero_rubinrothman_com

We will notify you as soon as the ticket will be resolved.