Hello,
I have a problem while using the Aspose.pdf for .NET.
Basic explanation: I am trying to create a PDF based on a constructed HTML code that is saved inside a string and return the PDF into a MemoryStream to pass it further in the code.
The following is the code in question:
Document doc = new Document();
doc.PageInfo.Width = PageSize.A4.Width;
doc.PageInfo.Height = PageSize.A4.Height;
doc.PageInfo.Margin.Top = 10;
doc.PageInfo.Margin.Bottom = 10;
doc.PageInfo.Margin.Left = 10;
doc.PageInfo.Margin.Right = 10;
Page page = doc.Pages.Add();
HtmlFragment htmlFragment = new HtmlFragment(finalStr);
page.Paragraphs.Add(htmlFragment);
fileStream = new MemoryStream();
doc.Save(fileStream);
fileStream.Seek(0, SeekOrigin.Begin);
Also, a bit earlier in the code I am setting a Aspose Total License too with the following code:
string licenseName = "Aspose.Total.NET.lic";
var license = new Aspose.Pdf.License();
license.SetLicense(licenseName);
The problem I’m facing is that when this line doc.Save(fileStream); is being executed, the code throws a Null reference exception and I tried researching what the problem might be but I’m out of ideeas. Can anyone help?
Edit: If needed, I can post an example of a constructed html as well.
Edit 2: finalStr contains the constructed HTML.