The code for this is ...
private Stream HtmlToPdf(string html, PageOrientation orientation, SizeF pageSize)
- Code: Select all
{
var stream = new MemoryStream();
Document document = new Document();
document.LoadHTML(new StringReader(html), XHTMLValidationType.None);
document.LastSection.PageSetup.PageSize = pageSize.IsEmpty ? PageSize.A4 : pageSize;
document.LastSection.PageSetup.Orientation = orientation;
document.SaveToStream(stream, Spire.Doc.FileFormat.PDF);
stream.Seek(0, SeekOrigin.Begin);
return stream;
}
Example Behavior of memory use after one request
Call - https://localhost:44308/enrollment/cust ... export/pdf
Startup 115 MB
Before method LoadHtml - 293 MB
After method LoadHtml - 1.8 GB
After SaveToStream - 2.7 GB
We have tried the newest hotfix version 6.4.4
This is a production issue so our second option is switching to another PDF generator that is actually working great with only 3 lines of code being altered. We would like to resolve this with Spire if we can.