Hi,
Environment: Aspose.PDF_10_3_0 and Aspose.PDF_10_9_0 versions.
I see an exception message: “A first chance exception of type ‘System.NullReferenceException’ occurred in Aspose.Pdf.dll” when I try to extract adobe fields using following code for the attached test document. Here is my code:
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(filename);
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form(pdfDocument);
//get all field names
String[] allfields = form.FieldNames;
Aspose.Pdf.PageCollection pageCollection = pdfDocument.Pages;
Aspose.Pdf.InteractiveFeatures.Forms.FormType formType = pdfDocument.Form.Type;
string fieldFullName = “”;
Aspose.Pdf.Facades.FormFieldFacade fieldfacade = null;
foreach (Aspose.Pdf.InteractiveFeatures.Forms.Field formField in pdfDocument.Form.Fields)
{
fieldFullName = formField.FullName;
try
{
fieldfacade = form.GetFieldFacade(fieldFullName); // GIVES EXCEPTION AT THIS LINE
}catch (Exception e){
Trace.Write(e.Message);
}
}
1. How can I handle this error?
2. What is a work around for this?
Thank you,
Sireesha
Hi Sireesha,
Thanks for using our API’s.
I have tested the scenario and I am able to notice the same problem. For the sake of correction, I have logged this problem as PDFNEWNET-39540 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.
I also have this error
Hi Birgit,
I’ve just seen your reply. Did you already find a solution? See attached the document which produces the exception.
Thanks,
Birgit
Hi Birgit,
Thanks for sharing your sample document. I have tested the scenario using Aspose.Pdf for .NET 11.1.0 and was unable to notice any exceptions. Please download and try the latest version of Aspose.Pdf for .NET, as it should resolve the issue. However, if the issue persists, please share your sample code here, and we will look into it and guide you.
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(@"C:\Users\Home\Downloads\ErhbgsBogStammdatenStromVersorgerId8674doc.pdf");
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form(pdfDocument);
// get all field names
String[] allfields = form.FieldNames;
Aspose.Pdf.PageCollection pageCollection = pdfDocument.Pages;
Aspose.Pdf.InteractiveFeatures.Forms.FormType formType = pdfDocument.Form.Type;
string fieldFullName = "";
Aspose.Pdf.Facades.FormFieldFacade fieldfacade = null;
foreach (Aspose.Pdf.InteractiveFeatures.Forms.Field formField in pdfDocument.Form.Fields)
{
fieldFullName = formField.FullName;
try
{
fieldfacade = form.GetFieldFacade(fieldFullName); // GIVES EXCEPTION AT THIS LINE
//pdfForm.FillField(fieldFullName, "44.name_vorname");
Console.WriteLine("field FullName: {0} page: {1}", formField.FullName, fieldfacade.PageNumber);
}
catch (Exception ex)
{
Trace.Write(ex.Message);
}
}
Please feel free to contact us for any further assistance.
Best Regards,