Apose PDF Document does not recognize numeric form fields

Attempting to retrieve all form fields from the following PDF:

https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/t4/t4-fill-14e.pdf

Using the following code:

    Document pdfDocument = new Document("t4-fill-14e.pdf");
   

    //get values from all fields
    foreach (Field formField in pdfDocument.Form.Fields)
    {
        Console.WriteLine("Field Name : {0} ", formField.PartialName);

        Console.WriteLine("Value : {0} ", formField.Value);
    }

Only the button and text fields are listed; the numeric fields and the drop-down fields are not. Is this a limitation of the API?

@RMD1

Thanks for contacting support.

We have tried to extract form fields from your PDF using Aspose.PDF for .NET 18.7 and were unable to notice any issue. Please check attached screenshot and following code snippet used for extracting the form fields information.

Document pdfDocument = new Document(dataDir + "t4-fill-14e.pdf");
// get values from all fields
foreach (Field formField in pdfDocument.Form.Fields)
{
 Console.WriteLine("Field Name : {0} ", formField.FullName);
 Console.WriteLine("Field Type : {0} ", formField);
 Console.WriteLine("Value : {0} ", formField.Value);

}
FieldNames.png (2.6 KB)

Please try again using latest version of the API and in case you still face any issue, please feel free to let us know.

Thanks for the quick feedback; this is very strange indeed.

Note that I am currently running a .NET Core 2.1 application, and installed Aspose via nuget - it appears to be the latest version, ie:

image.png (21.3 KB)

I modified the application code a bit to show all form field names, as well as field names exposed within the XFA, ie:

 Document pdfDocument = new Document("t4-fill-14e.pdf");

        Console.WriteLine("Form.Fields:");
        foreach (Field formField in pdfDocument.Form.Fields)
        {
            Console.WriteLine("Field Name : {0} ", formField.PartialName);
        }

        Console.WriteLine("----------------");
        Console.WriteLine("XFA data:");
        Console.WriteLine(pdfDocument.Form.XFA.FieldNames);
        foreach (var fieldName in pdfDocument.Form.XFA.FieldNames)
        {
            Console.WriteLine(fieldName);
        }

The Form.Fields only shows a subset of the total fields, however the XFA data does show all 81 fields, ie:

image.png (40.7 KB)

Is this possibly an issue with me using .NET Core?

@RMD1

Thanks for getting back to us.

This is not an issue with .NET Core version of the assembly but a limitation of trial version. It seems you are using API without setting a valid license. Due to limitation of trial version, you are unable to extract all fields using Document.Form.Fields approach. Whereas, Document.Form.XFA.FieldNames only represents names of the form fields as array of strings, which is why your program is returning all names of fields in this case.

Would you please try using a valid license and in case you do not have one, please consider applying 30-days temporary license in order to use and evaluate API without any limitations. In event of any further inquiry, please feel free to let us know.

Thanks Asad - this was indeed the issue; after obtaining a temporary license file, I was able to see all fields in the Form.Fields collection.

This limitation in the trial version is understandable, however not very discoverable - especially when installing the package via NuGet.

I initially assumed this was a limitation / defect with the product and was going to move on to evaluating another solution - your company may want to investigate a more effective means of limiting the trial version or making this type of limitation more visible (perhaps adding Debug or Console Writelines indicating that the trial version limits the number of fields displayed).

In any case, thank you for your assistance - I can now continue evaluating the product for inclusion within our RFP.

@RMD1

Thanks for sharing your concerns.

We definitely understand your concerns and have logged an enhancement request as PDFNET-45146 in our issue tracking system. We will further investigate how this enhancement can be implemented in case of trial version usage of the API. As soon as we make some progress towards implementation of the enhancement, we will let you know. Please spare us little time.

1 Like