ContextSwitchDeadLock

Hi,

I am trying to generate a PDF as a MemoryStream using the HtmlToPdfResult object. It seems that the Render method works on small webpages, but doesn't work on large webpages. I have placed two examples below.

Does anyone have an idea what the problem might be and how this can be fixed?

Kind regards,

Pierius


--- Small webpage ---

WebPage:
http://tezt.lubricantadvisor.com/Advice.aspx?Lang=Dan&type=%2bkj%2fTU0LRoSuB8%2fl3Cwj4Q%3d%3d

Pdf generation:
http://tezt.lubricantadvisor.com/Advice.aspx?Lang=Dan&type=%2bkj%2fTU0LRoSuB8%2fl3Cwj4Q%3d%3d&pdf=1&spdf=1

--- Large webpage ---
WebPage:
http://tezt.lubricantadvisor.com/Advice.aspx?Lang=Dan&type=ku0EwOu%2bzZ8wjDi0CN%2byCw%3d%3d

Pdf generation:
http://tezt.lubricantadvisor.com/Advice.aspx?Lang=Dan&type=ku0EwOu%2bzZ8wjDi0CN%2byCw%3d%3d&pdf=1&spdf=1


--- Method that handles the PDF generation ---

private void generate()
{
doc = new PdfDocument();

if (url.Equals(""))
{
failed = true;
return;
}

doc.FileStructure.CrossReferenceType = PdfCrossReferenceType.CrossReferenceTable;
doc.FileStructure.Version = PdfVersion.Version1_4;
doc.Compression = PdfCompressionLevel.BestSpeed;
doc.PageSettings.Orientation = PdfPageOrientation.Portrait;
PdfPage page = doc.Pages.Add();
SizeF pageSize = page.GetClientSize();

AddFooter(doc, "");

PdfUnitConvertor convertor = new PdfUnitConvertor();
float width = convertor.ConvertToPixels(page.GetClientSize().Width, PdfGraphicsUnit.Point);

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

HtmlToPdfResult result = html.Convert(url, ImageType.Metafile, (int)width, -1, AspectRatio.KeepWidth);

if (result == null)
{
failed = true;
return;
}

PdfMetafile mf = new PdfMetafile(result.RenderedImage as Metafile);
mf.Quality = 100;

PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Break = PdfLayoutBreakType.FitPage;
format.Layout = PdfLayoutType.Paginate;
doc.PageSettings.Height = result.RenderedImage.Size.Height;

format.SplitTextLines = false;
format.SplitImages = false;

result.Render(page, format);

mf.Dispose();
html.Dispose();
}

if (doc != null)
{
success = true;
failed = false;
}
else
{
failed = true;
}
}


5 Replies

GM Geetha M Syncfusion Team April 18, 2012 08:31 AM UTC

Hi Pierius,

Thank you for your interest in Syncfusion products.

I am afraid that the small and large webpage links are down. I had created a simple sample using your code snippet and it worked here. I had placed it in the following link:

LargeHTMLConv

Please try this and let me know if you have any other questions.

Regards,

Geetha



PI Pierius April 19, 2012 10:29 AM UTC

Hi Geetha,

Thanks for your answer.

I have placed the sample code on a test site:
http://syncfusion.lubricantadvisor.com/default.aspx

Unfortunately it does not work. Both sample sites, of my first post, are also in the air again.

I get the same problem. The small webpage works and large webpage does not. Your sample url has the same problem: a "request timed out".

In our company we are using syncfusion essential studio 8.2.0.18

Kind regards,

Pierius



GM Geetha M Syncfusion Team April 20, 2012 09:09 AM UTC

Hi Pierius,

Thank you for the details.

I was not able to reproduce the request timed out problem with the large webpage link you sent to us. Could you please let me know your machine configuration so that we can check and get back to you?

OS Version:

Bit type: (64 or 32 bit)

IE version:

Regards,
Geetha



PI Pierius April 23, 2012 08:25 AM UTC

Hi Geetha,

My local machine has the following configuration:
- Windows 7 64 bit
- IE 9.0.8112.16421

The server is running:
- Windows Server 2008 R2 64 bit
- IIS 7.5
- No IE installed (we placed the required microsoft.mshtml.dll file in the bin folder of the web application)

Kind regards,
Pierius



GM Geetha M Syncfusion Team April 26, 2012 06:23 AM UTC

Hi Pierius,

Thank you for the details.

I was not able to reproduce the problem in Windows 7 64 bit, IE 9. I had placed the test sample in the following link:
http://www.syncfusion.com/downloads/Support/DirectTrac/91999/LargeHTMLConv1473445020.zip

Could you please modify this sample and send back to me?

Regards,
Geetha


Loader.
Up arrow icon