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-okuand 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.