Hi there,
I'm am completely at a loss with a problem I am having with MigraDoc at the moment. I will try my best to explain, but please ask if you need anymore information. Sometimes when I call PdfDocumentRenderer's RenderDocument function, I am getting a NullReferenceException (Object reference not set to an instance of an object). I have managed to narrow this down to being something to do with when I'm adding a table to a section.
It makes no sense to me what so ever. The problem is intermittent and the same code is used everytime it is called. It can be called 8 times in the same document and work 7 of those times! By process of elimination, this line of code is what seems to be the cause of the exception:
Code:
table = section.AddTable();
(where table is of type Table and section of type Section).
And the code that actually throws the exception is (on the pdfRender.RenderDocument() line):
Code:
MigraDoc.Rendering.PdfDocumentRenderer pdfRender = new MigraDoc.Rendering.PdfDocumentRenderer(false, PdfSharp.Pdf.PdfFontEmbedding.Always);
pdfRender.Document = document;
pdfRender.RenderDocument();
Any idea's or suggestions you may have would be massively appreciated as I am now fresh out of ideas!
Thanks in advance,
Sarah