We are using below code to convert HTML to PDF.
- Code: Select all
Spire.Pdf.HtmlConverter.Qt.HtmlConverter.PluginPath = HttpContext.Current.Server.MapPath("~/bin/plugins/");
Logtxt += "ConvertHTMLStringToPDF Thread Start Time: " + string.Format("{0:yyyy-MM-dd hh:mm:ss:fff}", DateTime.Now) + ",";
Thread thread = new Thread(() =>
{
//convert the html to Pdf file, you could also convert it to PDF stream using the override method
Spire.Pdf.HtmlConverter.Qt.HtmlConverter.Convert(htmlString, filePath + fileName + ".pdf",
true,
10 * 1000,
new SizeF(612, 792),
new PdfMargins(0),
LoadHtmlType.SourceCode);
});
thread.SetApartmentState(ApartmentState.MTA);
thread.Start();
thread.Join();
Logtxt += "ConvertHTMLStringToPDF Thread End Time: " + string.Format("{0:yyyy-MM-dd hh:mm:ss:fff}", DateTime.Now) + ",";
Now the problem is while converting HTML to PDF for the first time it only took 2 seconds. But from second time on wards it is taking 10 to 12 seconds for HTML to PDF conversion. We would like to increase the HTML to PDF conversion efficiency here. What are we missing here? Please find the attached file for the HTML string that is being used to convert to PDF. By the way this logic has been implemented in ASP.NET MVC Web application.