Reputation: 191
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;
}
Upvotes: 2
Views: 1385
Reputation: 191
Many people have asked about APIs to convert HTML to PDF so I thought some might find our experience useful.
9 months later and we never heard back from HiQ support even though we are paying customers. We're finally in the last steps of going live with our reporting application and so wanted to improve the performance of our PDF rendering.
For small and even medium sized reports HiQ did fine but choked on a large HTML file. The version of the report I'm rendering was taking 52 seconds solely to convert the generated HTML to PDF. I tried updating to the newest version (current v14) of HiQ but that didn't help.
I spent the day testing multiple HTML to PDF conversion APIs. Here are the times it took for each to convert that same report:
HiQPdf- 52s
IronPdf- 22s
GemBox- 19s
SyncFusion- 22s
iText7- 76s
GemBox was the fastest but had some issues with our CSS/layout. I didn't spend time looking into fixing them so it would probably be fine, but we'll probably go with IronPdf or SyncFusion.
Upvotes: 0
Reputation: 2018
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
Upvotes: 1