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

ContextSwitchDeadLock

Thread ID:

Created:

Updated:

Platform:

Replies:

103259 Apr 17,2012 02:34 PM UTC Apr 26,2012 06:23 AM UTC ASP.NET Web Forms (Classic) 5
loading
Tags: PDF
Pierius
Asked On April 17, 2012 02:34 PM UTC

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;
}
}


Geetha M [Syncfusion]
Replied On 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


Pierius
Replied On 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


Geetha M [Syncfusion]
Replied On 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


Pierius
Replied On 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


Geetha M [Syncfusion]
Replied On 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


CONFIRMATION

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.

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

;