We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

PDF Form Flatten results in 'Object reference not set' on Save.

Thread ID:

Created:

Updated:

Platform:

Replies:

114155 Oct 31,2013 08:17 AM Apr 2,2018 01:20 AM Windows Forms 3
loading
Tags: PDF
Michael Keeman
Asked On October 31, 2013 08:17 AM

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) 

Praveenkumar H [Syncfusion]
Replied On November 6, 2013 11:37 PM

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





Ajmal jalal
Replied On March 30, 2018 11:10 PM

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

Sasi Kumar Sekar [Syncfusion]
Replied On April 2, 2018 01:20 AM

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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;