Free Support Forum -

Recieving Unable to cast object of type 'Aspose.Pdf.InteractiveFeatures.Annotations.WidgetAnnotation' to type 'Aspose.Pdf.InteractiveFeatures.Forms.Field' when accessing "FieldNames" property


I have a PDF AcroForm that I’m unable to process because I receive the following exception when using the “FieldsNames” property. Any help you can provide would be very appreciated.

Unable to cast object of type ‘Aspose.Pdf.InteractiveFeatures.Annotations.WidgetAnnotation’ to type ‘Aspose.Pdf.InteractiveFeatures.Forms.Field’"

The following code is enough to reproduce the exception:

string OriginalPdfPath = @“D:\temp\NCFAM94.pdf”;

Aspose.Pdf.Document doc = new Aspose.Pdf.Document(OriginalPdfPath);
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form(OriginalPdfPath);

string[] fields = form.FieldNames;

The PDF document used for this example is attached.

Additional information:
Using Aspose version
- I have downloaded and the same exception is thrown.

Hi Anthony,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the template file and sample code.

I am able to reproduce your mentioned issue after an initial test. For rectification, your issue has been registered in our issue tracking system with issue id: PDFNEWNET-34179. You will be notified via this forum thread regarding any update against your reported issue.

Sorry for the inconvenience,

The issues you have found earlier (filed as PDFNEWNET-34179) have been fixed in Aspose.Pdf for .NET 7.4.0.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.