Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Apr 16, 2020 12:51 pm

Hello Team,
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.

curvaturepdfapi
 
Posts: 32
Joined: Wed Apr 20, 2016 10:08 pm

Fri Apr 17, 2020 7:34 am

Hello,

Thanks for your inquiry.
I tested your case but didn’t reproduce your issue, each conversion takes about 2 seconds. Here I uploaded my testing project, please deploy it on your server and test. If the issue still occurs or your project is different from mine, please share a runnable project with us for further investigation. You could upload it to the DropBox or OneDrive and then share the download link with us.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.PDF