Rank: Member Groups: Member
Joined: 5/23/2013 Posts: 24
|
Hi, I use EO.Pdf.HtmlToPdf.ConvertHtml(outXml, pathPdfFile) to convert html text (outXml) to a pdf file in a ASP.NET MVC 2 application and render the pdf result to the user so he can download it . The problem is than the first time it takes a lot time to render the pfd, about 15 seconds. The following times I render the pdf correctly and it takes about 2 seconds but my problem is than the fisrt time I try to download it it takes 15 seconds and is too much time for the user. The outXml parameter contains images and text and I use the option EO.Pdf.HtmlToPdf.Options.BaseUrl = Server.MapPath("~/Content/images/") to improve the timing but without result. Any suggestion?
Regards,
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi, The first time takes much longer is because a lot of internal data are initialized on the first time. To avoid this problem, you can call some code like this when your application starts:
Code: C#
PdfDocument doc = new PdfDocument();
HtmlToPdf.ConvertHtml("anything", doc);
This does a conversion without creating any file. The result is discarded but after this the engine is fully initialized. This way when you need to actually convert real file for the user, it doesn't need to initialize again. Thanks!
|