|
Rank: Member Groups: Member
Joined: 1/13/2015 Posts: 14
|
Hi, We are planning to use EO.PDF to replace SyncFusion but encounter some performace problem. Summary : I have some MVC pages in our ASP.NET application which loads the data with Ajax call for some of the blocks. So when i call ConvertUrl to generate PDF document, the generated PDF document page is displayed without block details ( Data is not loaded for those blocks. Only header is displayed ). For work around i am using System.Windows.Form.WebBrowser to load all raw HTML data and then calling ConvertHtml to generate PDF document. But this is impacting the performance ( takes 70 secs to generate one page ). FYI - I have also tried with enabling Javascript option but no impact. Please help !!!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, Please try to increase HtmlToPdf.Options.MinLoadWaitTime. When EO.Pdf converts a page, it first load that page into it's internal browser engine, then wait for a short period of time before the conversion actually starts. This wait time is controlled by HtmlToPdf.Options.MinLoadWaitTime. The purpose of this wait period is to give the script in your web page sometime to run. In your case, it appears that this wait period wasn't long enough and the conversion started earlier before your AJAX script has fetched all the data from your server. Increasing HtmlToPdf.Options.MinLoadWaitTime should solve this problem for you. If you do not want to specify a fixed HtmlToPdf.Options.MinLoadWaitTime, you can use our manual trigger feature. The manual trigger allows you to explicitly tell the converter when to start conversion instead of just waiting for a specific amount of time. you can find more information on how to use manual trigger here: http://www.essentialobjects.com/ViewDoc.aspx#manual_trigger
Please feel free to let us know if you still have any more questions. Thanks!
|
|
Rank: Member Groups: Member
Joined: 1/13/2015 Posts: 14
|
HtmlToPdf.Options.MinLoadWaitTime didn't work for me as i have tried with 100 seconds as well.
For other option "Manual trigger", as we are using postbackUrl so i not sure when all request will be completed. Is it OKEY to call javascript function "eopdf.convert();" on Page life cycle of "OnLoadComplete".
But how am i going to collect data in PdfDocument? Do i need to call explicitly HtmlToPdf.ConvertUrl ?
Please advice !!!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, In that case you will want to troubleshoot the JavaScript in your page to make sure that it is indeed being called. You can use the debug console feature to add debug output: http://www.essentialobjects.com/doc/4/htmltopdf/js.aspxThere is no such thing as "calling JavaScript function eopdf.convert() on page life cycle of OnLoadComplete". OnLoadComplete happens on the server side inside your web server and eopdf.convert is a client side JavaScript that is called on the client side by the browser. So these two are completely unrelated. Also you never "collect data in PdfDocument" either. You do whatever you do to get your HTML right and then pass the HTML to our converter. So anything you do you do it in your HTML. Thanks!
|
|
Rank: Member Groups: Member
Joined: 1/13/2015 Posts: 14
|
Thanks for the response. I found the issue as EO use chrome inbuild engine to render pdf so one of the JavaScript was not triggered in chrome. Now it's fixed and working like charm ( without using any extra overload of web browser to download raw html before converting into pdf ).
However there is another issue found that HtmlToPdf.ConvertUrl is getting stuck during conversion for some of the page ( not every time ). How can we handle these scenario?
Is there any timeout option? Is it possible to relaunch the conversion after failed ?
Another query related to object dispose. How can we clean up the memory after conversion ? Do we need to do it explicitly or it will be done automatically ( as I didn't find any function like Document . Close () .
Please help !!!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
The time out is controlled by HtmlToPdf.Options.MaxLoadWaitTime. Note that the real time out value is based on MaxLoadWaitTime, but not the same value. There are a number of situations where you may receive timeout error. One situation is your HTML is too big, so it is unable to finish loading/conversion in time, another situation is it is waiting on the web server to serve the resource (for example, a dynamically generated image). Particularly, if you call ConvertUrl/ConvertHtml on the same web server then you can easily run into ASP.NET session lock issue. In that case you should use ASPXToPDF or MVCToPDF class instead.
You do not need to explicitly clean up with EO.Pdf if you use ASPXToPDF, MVCToPDF, or the static version of ConvertHtml/ConvertUrl. If you use HtmlToPdfSession object, then you will need to explicitly dispose that object.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 1/13/2015 Posts: 14
|
Hi,
Thanks for your reply and support so far !!!
I tried with HtmlToPdf.Options.MaxLoadWaitTime, but HtmlToPdf.ConvertUrl is getting sruck for longer time. I am sure its not the problem in loading data ( web page ). However i am getting timeout after 40 mins ( some good thing as its getting timeout ). Please note as of now this is happening ONLY for one of the web page. ( that also sometimes ).
Is there any way to configure this HtmlToPdf.ConvertUrl timeout ?
Another topic about watermark - so far i got 2 option i..e before and after render page and use PdfTextLayer. But there is problem in display of text as its getting hidden.
Do you have some other option ?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, If you are only getting timeout on a single page, then it's almost certain the problem is related to that page. You will want to try to comment out the code in your page block by block to find out exactly what triggered it. You can not configure HtmlToPdf.ConvertUrl time out directly. The only value you can change is HtmlToPdf.Options.MaxLoadWaitTime. The actual time out value is based on this value. You can not use before render event to render watermark. This is because an HTML file will always have a solid background (the default is white, obviously you can use CSS to change to something else). You should be able to use after render event to render watermark though. You can also render watermark after the conversion is done. For example:
Code: C#
//Convert the main output
PdfDocument doc = new PdfDocument();
HtmlToPdf.ConvertUrl(your_url, doc);
//Add watermark. Note the second argument is a PdfPage
//object, not a PdfDocument
HtmlToPdf.ConvertHtml("watermark", doc.Pages[0]);
Hope this helps. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/5/2015 Posts: 5
|
Hi,
Unfortunately still we have the issue in converting the MVC pages which has async ajax post into PDF files. HtmlToPdf.Options.MinLoadWaitTime is not working and even the java script change which was done is not fruitful as well.
In our case, normally async ajax post will take a bit of time to render due to web service calls. We would like to know whether there is any way we can make the EO component to wait until the whole page is rendered fully (including the ajax posts)?
Many thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
|
|
Rank: Newbie Groups: Member
Joined: 3/5/2015 Posts: 5
|
Hi, We have tried using the manual trigger, but it is not considering the MaxLoadWaitTime when we set it. It keeps waiting for a long time and the process never ends. This behaviour is not consistent and some times the manual trigger works fine.
Note: When we try to browse the same page through Chrome browser, it shows the content very well.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, The exact point of manual trigger is to disregard all the automatic waiting logics, including MaxLoadWaitTime. If you choose to use manual trigger but never actually call the trigger, then the conversion will time out. As such if you say you are going to call the manual trigger (by setting HtmlToPdf.Options.TriggerMode to Manual), then you must do what you say (calling eopdf.convert()). If you are not sure why eopdf.convert is not called, you can use the debugger console feature to debug your JavaScript to find out: http://www.essentialobjects.com/doc/4/htmltopdf/js.aspxThanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/5/2015 Posts: 5
|
Hi,
Thanks for your suggestion. Currently we are using the below code to make sure that we call eopdf.convert() after everything is loaded. $(window).load(function () { eopdf.convert(); });
But still the behavior is not consistent. 1. In some cases CSS are not fully loaded and it makes the converted PDF having texts without any styles. 2. Sometimes content is not fully loaded (but CSS is OK). 3. In some situation PDF generator freezes (may be waiting for eopdf.convert()). 4. Everything is 100% perfect on some occasions
My code & data set is same (i.e. content page is same); when we do the test we have the above inconsistent behavior. Is there any way we can make EO to wait for a fixed amount of time after calling eopdf.convert() from javascript?
Note: Currently I'm using TriggerMode as Dual (assuming that this option makes sure that the content is fully loaded after calling eopdf.convert()) TriggerMode Dual overrides the MaxLoadWaitTime (I feel it will be good if EO adheres this property even on Manual/Dual mode)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi Arun,
You definitely do not call eopdf.convert() from $(window).load. Doing so has absolutely no benefit.
The exact purpose of having you to call eopdf.convert() explicitly instead of automatically is so that you will ONLY call it when you are truly ready. For example, if you use AJAX call to load contents in your page, then you might not be ready UNTIL AFTER your AJAX calls are done. And because our converter would have no way of knowing when you have finished all your AJAX calls, the solution would be for you to use manual trigger and call eopdf.convert() AFTER you are done with your AJAX calls. The point is not just to make sure eopdf.convert() is called, but also only calls it when you are truly ready. We don't need you to tell us that your window's onload event has been fired. We can detect that automatically. So calling that from window.onload over the default automatic trigger would not solve any problems for you.
As previous replies have already pointed you, another option you can try is to increase MinLoadWaitTime. However this would not solve the problem of your AJAX calls might take longer than expected since whatever MinLoadWaitTime you set, it would always be a fixed value.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/5/2015 Posts: 5
|
Hi, Thanks for the reply. But when we try using the $(window).load event with an alert message, it works very well in the Chrome browser. Alert message is appearing only after all the content is loaded in the browser. This behaviour is also consistant with this document http://api.jquery.com/load-event/FYI, we have a huge content in the page, is there any limit on the size of the page? Sometimes EO fails to generate the PDF even with MinLoadWaitTime set to 5 minutes (with in this time for sure the page will be loaded) along with TriggerMode as Auto. Is there a way we can see whether there is any internal error in EO during PDF conversion or make EO to write the logs into a file? FYI, we have even made sure that the URL has been browsed and the last part of the process has been done for that page by writing a long in the web page itself. Thanks in advance!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Arun wrote:But when we try using the $(window).load event with an alert message, it works very well in the Chrome browser. Alert message is appearing only after all the content is loaded in the browser. This behaviour is also consistant with this document http://api.jquery.com/load-event/ We are not sure how we can explain it better. $(window).load is for the initial load. But you are talking about AJAX calls. These are two different things. If you have no AJAX calls and everything in your page is ready on $(window).load then you do not need to do anything special. By default, our converter will wait for that before starting the conversion. If your page uses AJAX calls, the the converter will not know when you are done with those calls. That's when you may need manual trigger. This has everything to do with your AJAX calls and has NOTHING to do with $(window).load. Arun wrote:FYI, we have a huge content in the page, is there any limit on the size of the page? Sometimes EO fails to generate the PDF even with MinLoadWaitTime set to 5 minutes (with in this time for sure the page will be loaded) along with TriggerMode as Auto. There is no fixed limit because it all depends on your system. You will need to reduce your file size if you keep running into problems. Arun wrote:Is there a way we can see whether there is any internal error in EO during PDF conversion or make EO to write the logs into a file? FYI, we have even made sure that the URL has been browsed and the last part of the process has been done for that page by writing a long in the web page itself. You can only see JavaScript errors. Please see here for more details (look for "Debug Console" section): http://www.essentialobjects.com/doc/4/htmltopdf/js.aspxThanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/5/2015 Posts: 5
|
Hi,
For now we have used webbrowser control to extract the HTML and passed it to EO to generate the PDF. Many thanks for your support & suggestions.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
You are very welcome. Glad that you found a workaround. Please let us know if you still have any questions.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 1/13/2015 Posts: 14
|
Hi Again,
I have removed the additional web browser control to extract the raw HTML and directly using the HtmlToPdf.ConvertUrl method.
The result is inconsistent. For the first few run i am able to generate PDF file successfully but after that it is failing to run the Jquery for the same file. ( For MVC pages ). This result in partial rendering of page in PDF file.
FYI - I am using Windows service to trigger the PDF generation.
Is there any added value to use HtmlToPdfOptions's NoCache property ? ( As of now i am not using this property. Whats the default value for this).
This is very urgent issue and one the show stopper to use this product any more.
Thanks, Ranjeet KUMAR
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi Ranjeet,
We do not have any other suggestions except for:
1. Using manual trigger properly; 2. Use the JavaScript debug console feature to find out whether a JavaScript error has occurred when the conversion result is not correct;
Both points have already been suggested previously in this thread. You must follow those first. We don't work in "let's try this let's try that" and see which one sticks approach.
Thanks!
|
|