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

Timeout when converting HTML to PDF Options
Canvas Tech
Posted: Wednesday, March 13, 2019 2:07:31 PM
Rank: Newbie
Groups: Member

Joined: 7/23/2018
Posts: 6

hope you are doing well. We have been facing intermediate issues where conversion from html (url) to pdf is throwing a timeout. We don't see this every day but some times timed out error is happening. Retrying the same conversion always works so it's not an issue with data no being available or the size of the data.

Do you know what can cause this error? So we can take preventive measurements.

Conversion failed. Operation timed out.Type: EO.Pdf.HtmlToPdfExceptionsource: EO.PdfStackTrace: at EO.Pdf.HtmlToPdfException.b(Exception A_0)
at EO.Internal.a3g.a(agd A_0)
at EO.Pdf.HtmlToPdfSession.RenderAsPDF(PdfDocument doc)
at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc, HtmlToPdfOptions options)
at EO.Pdf.HtmlToPdf.ConvertUrl(String url, Stream stream, HtmlToPdfOptions options)
at Canvas.Service.Utilities.DailyUtil.GetDailyCheckPreviewPdf(Int64 dailyId, String userId)
20190307- ::svcCanvasPubRW :: ERROR :: Operation timed out.Type: System.Exceptionsource: EO.PdfStackTrace: at EO.Internal.pe.b()
at EO.Internal.pe.a(HtmlToPdfOptions A_0, Single A_1, Single A_2, amh A_3, List`1 A_4, agd A_5)
at EO.Internal.a3g.a(agd A_0, Single& A_1)
at EO.Internal.a3g.a(agd A_0)

Our code:

Code: C#
EO.WebBrowser.ThreadRunner threadRunner = new EO.WebBrowser.ThreadRunner(Guid.NewGuid().ToString());
                EO.WebBrowser.WebView webView = threadRunner.CreateWebView();
                HtmlToPdfOptions op = new HtmlToPdfOptions();
                op.PageSize = new SizeF(8.5f, 11.69f);
                op.OutputArea = new RectangleF(0, 0, 8.5f, 11.69f);

                op.TriggerMode = HtmlToPdfTriggerMode.Dual;

                op.BeforeRenderPage = new PdfPageEventHandler(On_BeforeRenderPage);
                op.AfterRenderPage = new PdfPageEventHandler(On_AfterRenderPage);

                HtmlToPdf.Options.NoCache = true;
                //Lowering quality of images so that conversion will be faster
                HtmlToPdf.Options.JpegQualityLevel = 100;

                HtmlToPdf.Options.MaxLoadWaitTime = 60000;
                HtmlToPdf.Options.RetrieveNodeText = false;

                op.UserName ="user"
                op.Password = "pass"

                MemoryStream ms = new MemoryStream();

                HtmlToPdf.ConvertUrl(string.Format(dailyPreviewUrl, dailyId, ""), ms, op);

                //Save to memory stream and return back

                return ms.ToArray();


Posted: Friday, March 15, 2019 11:15:48 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 21,292

The most likely reason for this is a simple system overload issue. In this case there isn't much you can do. What you can try to do is to add logs with information about each conversion you are trying to perform, and then try to match that log with your IIS logs and see if you can find any clues from there. Because HTML to PDF converter will wait for all dependency resources in the HTML file to finish load before converting, a small image that takes a long time to load (such as dynamically generated chart image) can potentially hold up the conversion and cause the conversion to time out. So that might be where you want to check.


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.