'C# HiQ Html to PDF Performance Issue
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.
Solution 1:[1]
I finally received a response from the support: my serial is valid for a PREVIOUS version of HiQPdf.
Be aware that in Nuget, the only version available is version 12. To downgrade you need to find a backup of your previous version of HiQPdf.dll and put it manually in you packages.
Below the response from the support:
HiQPdf Sales [email protected] Mon 18/04/2022 18:20
Hello,
Your serial number is for version 10 of the software. For version 12 you need a new serial number.
You can renew the old license with a 20% renewal discount to obtain a serial number for the latest version of the software in the page below: [link removed]
Best Regards,
Jacob
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Emmanuel Gleizer |