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)