We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Conversion timeout when generating PDF

Thread ID:





104017 Jun 15,2012 09:28 AM UTC Jun 21,2012 04:18 AM UTC ASP.NET Web Forms (Classic) 8
Tags: PDF
Asked On June 15, 2012 09:28 AM UTC

Dear Support,

We use the following SyncFusion method in order to convert HTML from secured web page to PDF:

public Syncfusion.Pdf.HtmlToPdf.HtmlToPdfResult Convert(string url, Syncfusion.HtmlConverter.ImageType type, int width, int height, Syncfusion.HtmlConverter.AspectRatio aspectRatio, string username, string password)

The problem is we sometimes have conversion timeout - it happens occasionally and it does not depend on HTML size (no more than 1-3 Mb). We use STA thread to execute HtmlConverter method. The following code leads to timeout:

            Thread thread = new Thread(threadStart);

            if (!thread.Join(30000))
                throw new Exception("Conversion Timeout");

Server settings: Windows 2008 Server, 64bit, IE9/IE8

Could you please assist? 
Looking forward to your reply.

Best regards,

Replied On June 18, 2012 09:40 AM UTC

Any ideas? Thanks in advance.

Geetha M [Syncfusion]
Replied On June 18, 2012 11:39 AM UTC

Hi Natalya,

Sorry for the delay.

The HTML converter navigates to the specified HTML (a WebBrowser control is been used internally) and converts it to Image. The image conversion starts only after the document completion event is fired. After this, the image is drawn into PDF. The image to PDF conversion always take same time duration for a HTML. However, the document completion depends on download speed, server accessibility etc. Please check this and let me know if you have any questions.


Replied On June 18, 2012 02:50 PM UTC

Hi Geetha M,

Thanks for your quick response.

There is no downtime when opening HTML page in IE browser under user account we use to render PDF. Are there any other reasons why thread may hang? Could you please review the following code:

public static MemoryStream Convert(byte[] content, string uriString, bool isAttachment, string userName = null, string password = null)
            PdfDocument pdfDocument;

            pdfDocument = new PdfDocument();
            pdfDocument.PageSettings.Orientation = PdfPageOrientation.Portrait;
            PdfPage page = pdfDocument.Pages.Add();

            PdfUnitConvertor convertor = new PdfUnitConvertor();
            float width = -1;
            float height = -1;

            SizeF pageSize = page.GetClientSize();
            width = convertor.ConvertToPixels(pageSize.Width, PdfGraphicsUnit.Point);

            using (HtmlConverter html = new HtmlConverter())
                html.EnableJavaScript = true;
                html.AutoDetectPageBreak = true;
                html.EnableHyperlinks = false;

                    using (HtmlToPdfResult result = html.Convert(uriString, ImageType.Metafile, (int)width, (int)height, AspectRatio.KeepWidth, userName, password))
                        if (result.RenderedImage == null)
                            throw new Exception("Error Randering HTML Image");
                        PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
                        format.Break = PdfLayoutBreakType.FitPage;
                        format.Layout = PdfLayoutType.Paginate;
                        format.SplitTextLines = false;
                        format.SplitImages = true;

                        result.Render(page, format);
                MemoryStream resultStream = new MemoryStream();
                return resultStream;

Note, that stream size is no more than 3Mb, therefore it is unclear why it takes so long to execute (we experience 30 sec timeout).

Have you encountered any similar problems with methods HtmlToPdfResult.Render or PdfDocument.Save? Can they cause any memory leaks, etc? Looking forward to your reply.

Geetha M [Syncfusion]
Replied On June 19, 2012 10:54 AM UTC

Hi Natalya,

Thank you for the code snippet.

No, we have not encountered memory leak problem with HTML conversion. Could you please send us HTML as well so that we can check here? You may also create a new direct trac incident with details.


Replied On June 19, 2012 12:01 PM UTC

Hi Geetha M,

Thank you for your assistance. 
Please find the original html file with images enclosed.

Kind regards,


Geetha M [Syncfusion]
Replied On June 20, 2012 11:24 AM UTC

Hi Natallia,

Thank you for the details.

I tried to convert the HTML you sent to us and it converted to PDF in 6 seconds with Essential Studio version 10.2. Could you please let us know the Essential Studio version? Also, please send us the following details:

1. OS Version
2. Bit type (32 or 64 bit)
3. IE version


Replied On June 20, 2012 12:32 PM UTC

We user version, Windows 2008 Server OS, 64 bit.
Probably, we need to try the latest version of your product.
Thank you.

Geetha M [Syncfusion]
Replied On June 21, 2012 04:18 AM UTC

Hi Natallia,

Thank you for the details.

Please let us know if you have any other questions.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon