PDF Form Flatten results in 'Object reference not set' on Save.
I can load a different PDF files, insert values in PdfLoadedTextBoxField without problems.
But when I Flatten and Save a PDF i get an NullReferenceException.
We use 3 different PDFs. With 2 of them I don't get the exception and the save works perfect, but with one of them I do get an exception.
If I try to save without using Flatten, the PDF gets saved and no Exception occurs.
I think its the PDF itself. But all the PDFs are almost identical copies.
I hope someone can help me figure this out.
Code:
form.Flatten = true;
DirectoryInfo directory = new DirectoryInfo(Path.Combine(this.ServerFolder,this.Batch.ToString()));
if (!directory.Exists) directory.Create();
document.Save(Path.Combine(directory.FullName, data.Number + ".pdf"));
Stacktrace:
at Syncfusion.Pdf.Parsing.PdfLoadedTextBoxField.Draw()
at Syncfusion.Pdf.Parsing.PdfLoadedForm.Dictionary_BeginSave(Object sender, SavePdfPrimitiveEventArgs ars)
at Syncfusion.Pdf.Primitives.PdfDictionary.OnBeginSave(SavePdfPrimitiveEventArgs args)
at Syncfusion.Pdf.Primitives.PdfDictionary.Save(IPdfWriter writer, Boolean bRaiseEvent)
at Syncfusion.Pdf.Primitives.PdfDictionary.Save(IPdfWriter writer)
at Syncfusion.Pdf.IO.PdfCrossTable.DoSaveObject(IPdfPrimitive obj, PdfReference reference, PdfWriter writer)
at Syncfusion.Pdf.IO.PdfCrossTable.SaveIndirectObject(IPdfPrimitive obj, PdfWriter writer)
at Syncfusion.Pdf.IO.PdfCrossTable.SaveObjects(PdfWriter writer)
at Syncfusion.Pdf.IO.PdfCrossTable.Save(PdfWriter writer)
at Syncfusion.Pdf.Parsing.PdfLoadedDocument.AppendDocument(PdfWriter writer)
at Syncfusion.Pdf.Parsing.PdfLoadedDocument.Save(Stream stream)
at Syncfusion.Pdf.PdfDocumentBase.Save(String filename)
SIGN IN To post a reply.
5 Replies
PH
Praveenkumar H
Syncfusion Team
November 7, 2013 04:37 AM UTC
Hi Michael,
Thank you for using Syncfusion products,
Please provide us the sample pdf document which reproduces the issue, and also provide us the essential studio version details,it will help us to investigate further in this issue.
Please let us know if you need further assistance,
With Regards,
Praveen
I can load a different PDF files, insert values in PdfLoadedTextBoxField without problems.But when I Flatten and Save a PDF i get an NullReferenceException.We use 3 different PDFs. With 2 of them I don't get the exception and the save works perfect, but with one of them I do get an exception.If I try to save without using Flatten, the PDF gets saved and no Exception occurs.I think its the PDF itself. But all the PDFs are almost identical copies.I hope someone can help me figure this out.Code:form.Flatten = true;DirectoryInfo directory = new DirectoryInfo(Path.Combine(this.ServerFolder,this.Batch.ToString()));if (!directory.Exists) directory.Create();document.Save(Path.Combine(directory.FullName, data.Number + ".pdf"));Stacktrace:at Syncfusion.Pdf.Parsing.PdfLoadedTextBoxField.Draw()at Syncfusion.Pdf.Parsing.PdfLoadedForm.Dictionary_BeginSave(Object sender, SavePdfPrimitiveEventArgs ars)at Syncfusion.Pdf.Primitives.PdfDictionary.OnBeginSave(SavePdfPrimitiveEventArgs args)at Syncfusion.Pdf.Primitives.PdfDictionary.Save(IPdfWriter writer, Boolean bRaiseEvent)at Syncfusion.Pdf.Primitives.PdfDictionary.Save(IPdfWriter writer)at Syncfusion.Pdf.IO.PdfCrossTable.DoSaveObject(IPdfPrimitive obj, PdfReference reference, PdfWriter writer)at Syncfusion.Pdf.IO.PdfCrossTable.SaveIndirectObject(IPdfPrimitive obj, PdfWriter writer)at Syncfusion.Pdf.IO.PdfCrossTable.SaveObjects(PdfWriter writer)at Syncfusion.Pdf.IO.PdfCrossTable.Save(PdfWriter writer)at Syncfusion.Pdf.Parsing.PdfLoadedDocument.AppendDocument(PdfWriter writer)at Syncfusion.Pdf.Parsing.PdfLoadedDocument.Save(Stream stream)at Syncfusion.Pdf.PdfDocumentBase.Save(String filename)
Yes
SK
Sasi Kumar Sekar
Syncfusion Team
April 2, 2018 05:20 AM UTC
Hi Ajmal,
Thank you for contacting Syncfusion.
We have created the PDF document with the Textbox field and flattened. The reported “Null reference exception” is not reproduced in our side and it seems to be document specific issue. Can you please share the input PDF document and Essential Studio version which reproducing issue in your side? It will help us to analyze further and provide the solution earlier.
Regards,
Sasi Kumar S.
NH
Nitin Hodgar
April 14, 2021 10:14 AM UTC
Hi Team,
I am facing same exception. Please let me know how this has been resolved.
Kind regards,
Nitin Hodgar
SN
Santhiya Narayanan
Syncfusion Team
April 15, 2021 05:26 PM UTC
Hi Nitin,
Thank you for your interest with Syncfusion products.
Kindly share the code snippet, input PDF document, product version to reproduce the issue in our side, it will be helpful for us to reproduce the reported issue in our side. So that we can check and provide the solution as soon as possible.
Regards,
Santhiya.
SIGN IN To post a reply.
- 5 Replies
- 6 Participants
-
MK Michael Keeman
- Oct 31, 2013 12:17 PM UTC
- Apr 15, 2021 05:26 PM UTC