Below I’ve attached a PDF that was retrieved from a Canadian immigration website. When opened using Aspose.PDF, I am unable to get the field names of the document - it returns an index-out-of-bounds error (“Index was outside the bounds of the array”) whenever I run something like the following code:
Dim Document = New Aspose.Pdf.Document(SourceFile)
Dim Form = New Aspose.Pdf.Facades.Form(Document)
For Each FieldName in Form.GetFieldNames
Sorry - accidentally hit tab and it apparently submitted for me. I’ll start over:
Below I’ve attached a PDF that was retrieved from a Canadian immigration website. When opened using Aspose.PDF, I am unable to get the field names of the document - it returns an index-out-of-bounds error (“Index was outside the bounds of the array”) whenever I run something like the following code:
Dim Document = New Aspose.Pdf.Document(SourceFile)
Dim Form = New Aspose.Pdf.Facades.Form(Document)
For Each FieldName in Form.FieldNames
’ Do Something Here
Next
The error happens in the call to FieldNames on the Form object. Can this be fixed, or is there something else we can do to get access to the field names in the document?
I have worked with the data shared by you and have been able to reproduce the issue in our environment. A ticket with ID PDFNET-44338 has been logged in our issue management system for further investigation and resolution. The issue ID has been linked with this thread so that you will receive notification as soon as the issue is resolved.
However, you can use below code snippet to get field names from a PDF document, with Aspose.PDF for .NET 18.2:
Dim pdfDocument = New Document(dataDir + "Sample.pdf")
'Get names of XFA form fields
Dim names As String() = pdfDocument.Form.XFA.FieldNames
Dim counter As Integer = 0
Do While (counter < names.Length)
Console.WriteLine(names(counter))
counter = (counter + 1)
Loop
I hope this will be helpful. Please feel free to let us know if you need any further assistance.
We are afraid PDFNET-44338 is still pending for investigations owing to critical and previously logged tickets. It will be scheduled on its due turn. We will let you know as soon as some significant updates will be available. We appreciate your patience and comprehension in this regard.
If you are subscribed to Paid Support, then please request over Paid Support Helpdesk while referring to the ticket ID PDFNET-44338 and the priority will be raised accordingly. If you face any problem while signing in there, then you may create a topic in Purchase Forum and we will assist you accordingly.