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. Image for the cookie policy date
close icon

Error When calling PdfDocument.Save()

When saving a newly created pdf document I am getting a null reference exception.

Stack Trace:
at Syncfusion.Pdf.Primitives.PdfReferenceHolder.get_Index()
at Syncfusion.Pdf.Primitives.PdfReferenceHolder.ObtainObject()
at Syncfusion.Pdf.Primitives.PdfReferenceHolder.get_Object()
at Syncfusion.Pdf.Primitives.PdfReferenceHolder.Save(IPdfWriter writer)
at Syncfusion.Pdf.Primitives.PdfDictionary.SaveItems(IPdfWriter writer)
at Syncfusion.Pdf.Primitives.PdfDictionary.Save(IPdfWriter writer, Boolean bRaiseEvent)
at Syncfusion.Pdf.Primitives.PdfDictionary.Save(IPdfWriter writer)
at Syncfusion.Pdf.Primitives.PdfDictionary.SaveItems(IPdfWriter writer)
at Syncfusion.Pdf.Primitives.PdfDictionary.Save(IPdfWriter writer, Boolean bRaiseEvent)
at Syncfusion.Pdf.Primitives.PdfDictionary.Save(IPdfWriter writer)
at Syncfusion.Pdf.Primitives.PdfDictionary.SaveItems(IPdfWriter writer)
at Syncfusion.Pdf.Primitives.PdfDictionary.Save(IPdfWriter writer, Boolean bRaiseEvent)
at Syncfusion.Pdf.Primitives.PdfDictionary.Save(IPdfWriter writer)
at Syncfusion.Pdf.IO.PdfArchiveStream.SaveObject(IPdfPrimitive obj, PdfReference reference)
at Syncfusion.Pdf.IO.PdfCrossTable.DoArchiveObject(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.PdfDocument.Save(Stream stream)
at Syncfusion.Pdf.PdfDocumentBase.Save(String filename)
at .BusinessObjects.PDFMerge.FilesMerge(Int32 workOrderNumber, Int32 district, Int32 school, DateTime testBeginDate, Boolean IsPartial) in C:\\Users\\\\source\\repos\\RemoteDownload\\\\BusinessObjects\\PDFMerge.cs:line 78
at ..PDFMerge() in C:\\Users\\\\source\\repos\\RemoteDownload\\\\.cs:line 58
at ..Execute(TestScoreFile testScoreFile, BubbleFormWorkOrder workOrder) in C:\\Users\\\\source\\repos\\RemoteDownload\\\\.cs:line 35
at .Program.Main(String[] args) in C:\\Users\\\\source\\repos\\RemoteDownload\\\\Program.cs:line 31"

2 Replies

SL Sowmiya Loganathan Syncfusion Team October 30, 2019 09:51 AM UTC

Hi Aaron, 

Thank you for contacting Syncfusion support.  

We have checked the mentioned issue with the provided stack trace. We suspect that this issue occurs due to disabling of “EnableMemoryOptimization” property. In older version by default we have perform merge function by clone each and every objects from existing PDF document and dispose it. But effective from product version 17.1.0.32, we did not process the above. The existing PDF document will dispose only after saving of merged PDF document. However you can overcome this by set true to “EnableMemoryOptimization” of PDF document. 

Please refer the below KB link for more details, 

Please try the above solution in your end and let us know if it solves the issue. If not please share us the PDF documents which you have used in your end. It will helpful for us to provide the precise solution on this.  

Regards, 
Sowmiya Loganathan 




AK Aaron Knipe October 30, 2019 01:22 PM UTC

This solves my problem thank you!

Loader.
Live Chat Icon For mobile
Up arrow icon