Logo
My Account |  Site Map | Contact Us  
Welcome Guest Search | Active Topics | Sign In | Register

EO.Pdf HTML to PDF conversion takes a long time Options
An
Posted: Monday, June 15, 2020 5:59:40 PM
Rank: Newbie
Groups: Member

Joined: 3/23/2020
Posts: 2
I upgraded newest version of EO.Pdf. (latest dlls 20.1.45.0 with new key)

EO.Pdf HTML to PDF took longer than expected sometimes, or it timeout with a blank content.
I have adjusted MinTimeLoad = 10 seconds and MaxTimeLoad = 35 seconds.


here is sample codes :
var options = new HtmlToPdfOptions
{
MinLoadWaitTime = 10000,
MaxLoadWaitTime = 35000,
AutoFitX = HtmlToPdfAutoFitMode.ScaleToFit,
PageSize = new SizeF(PdfPageSizes.A4.Height, PdfPageSizes.A4.Width),
OutputArea = new RectangleF(
0, verticalTopMargin,
PdfPageSizes.A4.Height,
PdfPageSizes.A4.Width - verticalTopMargin - verticalBottomMargin),
FooterHtmlFormat = "<span style='float: right;font-size: 12px;padding: 0;margin: 0 30px 0 0;'>Page {page_number}-{total_pages}</span>"
};
var pdfDocs = Enumerable.Empty<PdfDocument>();
foreach (var url in urls)
{

var pdfDocument = new PdfDocument { EmbedFont = false };
HtmlToPdf.ConvertUrl(url, pdfDocument, options);
pdfDocs = pdfDocs.Concat(pdfDocument.Yield());
}

your help is appreciated.

Thanks,
An
eo_support
Posted: Tuesday, June 16, 2020 11:46:43 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 22,273
Hi,

The most common cause for conversion delay is during the loading stage, not during the conversion stage. When you call ConvertUrl, the internal browser engine would try to load that Url, wait for the entire paging as well as dependency resources (JavaScript, images, etc) to finish loading before conversion start. Most of the time the delay occurs while the converter is waiting for those resources to be loaded.

If you have access to the web server, you can check the web server's log to see if there is anything holding up there. For example, if your page contains a chart that is dynamically generated from a database, and the code that access the database takes a long time, then that will hold up the image and subsequently hold up the converter. You should be able to see this kind of delays from your web server logs.

If you not have access to the web server, you can use a traffic monitor to monitor the traffic between the converter and the web server. If there is any delay in the communication, the traffic monitor should show it as well.

Thanks!
An
Posted: Thursday, July 9, 2020 10:00:14 AM
Rank: Newbie
Groups: Member

Joined: 3/23/2020
Posts: 2
Hi,

After we upgraded to the newest version, we have an issue with pages data not being rendered on a DotNet application, we are trying to make PDFs from using url conversion. Page contain charts that dynamically generated from a database. Some page returns in second, some other pages take longer depend on how complex of the chart / query. Per your suggestion, we have monitor the traffic and nothing holding up in web server log.
The suggestion to use min-wait-time is also not working for our cases. The target pages to be converted into PDF may vary from single page to many, data-"heavy" pages, Thus in order to be sure, we would need to impose a min. wait time of several seconds. Data doesn’t load that slow, but if we go close to the actual load time, eo.pdf begins conversion before data is ready anyway making rendering of the dynamic portions of the page dependent on data-fetch being completed doesn’t work either and the result is back content for some data heavy pages, and the performance is slow.

Other option that we have tried: HtmlToPdfTriggerMode.Auto - per your definition “Automatically triggers conversion as soon as the page contents (styles, images, etc) are loaded “. This option is no longer working in the newest version. It worked in old version.
Would you please look into your HtmlToPdfTriggerMode.Auto for the newest EOPDF version?

Any suggestions are appreciated.

Kind regards,
eo_support
Posted: Thursday, July 9, 2020 10:41:27 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 22,273
Hi,

For TriggerMode.Auto it only check script/image tags. However if you dynamically generates chart with JavaScript, it is not possible for the converter to know exactly when you have finished generating your chart. The only two options for you is either you always wait for a long time, or you explicitly "tell" the converter that your contents are ready and the converter can start. To use the second option you can use manual trigger:

https://www.essentialobjects.com/doc/pdf/htmltopdf/trigger.aspx

The reason that the converter can't tell when your JavaScript code has finished generating your chart because there is no clear definition about "finish" on anything in a web page. For example:

1. If your web page contains a digital clock that keeps ticking forever (updated by JavaScript code), then obviously there is no definition of "finish" in this page;
2. If your page contains a JavaScript generated bar chart, but your code plays an animation so that the bar grows from zero height to full height, then there is no way the converter engine will know when your bar has finished growing;

The only way to precisely capture when your wanted to capture is for you to explicitly tell the converter when to capture the output. If that is not doable, then the only option is for you to wait long enough.

Hope this makes sense to you.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.