I'm working on a reporting project in C# that uses Razor pages to generate HTML and HiQ to convert the HTML to PDF. It's been working just fine until we added a new report that has lots of data- the raw data is 2.5mb saved as a text file and the end result is a 5.8m 200 page pdf.
The conversion process is taking unacceptably long for this report- 1.5 minutes. As a test we dropped in the old code that used OpenHtmlToPdf* which ran the same report in 20 seconds.
Is there a way of tweaking our code or the HiQ engine to improve performance?
Our code:
public Stream ConvertToPdf(string html, ReportSettings reportSettings)
{
var htmlToPdf = new HtmlToPdf();
htmlToPdf.SerialNumber = SerialNumber;
if (reportSettings.Landscape)
{
htmlToPdf.Document.PageOrientation = PdfPageOrientation.Landscape;
}
htmlToPdf.Document.PageSize = PdfPageSize.Letter;
htmlToPdf.Document.Margins = new PdfMargins(25, 25, 15, 15);
SetFooter(htmlToPdf);
var pdfData = htmlToPdf.ConvertHtmlToMemory(html, Url);
var memoryStream = new MemoryStream(pdfData);
return memoryStream;
}
- We switched to HiQ because OpenHtmlToPdf is no longer being updated and doesn't support CSS3.