Welcome Guest Search | Active Topics | Sign In | Register

Conversion failed Out Of Memory EO.Pdf.HtmlToPdf.ConvertUrl Options
Interpress
Posted: Tuesday, February 2, 2016 4:43:33 AM
Rank: Newbie
Groups: Member

Joined: 2/2/2016
Posts: 1
Hello,
I read in your forum about out of memory Exception when converting html to pdf and you answered that maybe the html content is big but not in my case.

I am using this code to convert html to pdf:
Code: C#
try
            {
                WebClient webClient = new WebClient();

                var data = webClient.DownloadString(link);

                HtmlToPdf.Options.OutputArea = new RectangleF(0, 0, 0, 0);

                HtmlToPdf.Options.NoLink = true;

                HtmlToPdf.Options.NoScript = false;

                HtmlToPdf.Options.ZoomLevel = float.Parse("0.6", CultureInfo.InvariantCulture);

                HtmlToPdf.Options.HeaderHtmlFormat = CreateHeader(mediaName, publishDate, link);

                HtmlToPdf.Options.FooterHtmlFormat = "<hr size='1px' color='gray'/><div style='font-family:times new roman; font-size:13pt; font-weight:bold;'>Interpress Medya Takip Merkezi</div><div style='text-align:right; margin-top:-17px; font-family:times new roman; font-size:13pt; font-weight:bold;'>Sayfa: {page_number} / {total_pages}</div>";

                HtmlToPdf.ConvertHtml(data, outputFileName);            }

            catch (Exception ex)
            {

                throw new Exception(ex.Message);
            }


I have two points:
First: I read in your documentation that your DLL is thread safe, but when I run this code in non-multithreading environment everything is good and the code run perfectly, But when I run this code in multithreading environment I got this exception :

Conversion failed. Exception of type 'System.OutOfMemoryException'.

In this line: HtmlToPdf.ConvertHtml(data, outputFileName); from my code.

Second: I tested this code on this link:
http://www.kizlarsoruyor.com/haber/q4580548-oku
and you can see that this page size is small which is (1.1)MB

could you please help me in this problem ASAP.
Thanks in advance.
eo_support
Posted: Tuesday, February 2, 2016 10:53:03 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

There is no fixed rule to say how big the HTML file can be because each HTML file is different. A 1.1 MB HTML file with a lot images will be much more different than a 1.1 MB file with just text. The same for multi-threading. Each additional thread costs extra resources, so it doesn't mean that if the code runs fine in a single thread so it should run fine with multi-thread as well. As such I would still recommend you reducing the size of your input file to avoid this error.

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.