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

HTML - PDF on deployment

Thread ID:





72525 Mar 25,2008 01:19 PM UTC Mar 27,2008 07:31 AM UTC ASP.NET Web Forms (Classic) 3
Tags: PDF
Asked On March 25, 2008 01:19 PM UTC


We have an issue converting HTML to PDF on the deployment server. Exception is thrown when we try to convert to Image Htmlconverter.ConvertToImage.
The same code works when we create a IIS virtual path & publish the website, but this fails thru deployment server i.e. running through VS05 (cassini). When we deploy on our farm servers it stiill doesnt work.
will appreciate a quick solution. using 5.14version

Administrator [Syncfusion]
Replied On March 26, 2008 12:20 PM UTC

Hi Sid,

Thank you for your interest in Syncfusion products.

An issue converting HTML to PDF on the deployment server:

I am not able to reproduce the issue that you mentioned here. I have tested this issue in Windows xp with service pack2, VS 2005, .Netframework 2.0, Acrobat Reader 7.0, v6.1.0.34 & v5.1.1.47. But the issue not reproduced.

Please follow this document to deploy the web project:

Please try this and if still the issue exists please send us the sample in which the issue caused so that we could give you a better solution. Also please provide your system details and specify the version correctly.


Replied On March 26, 2008 08:58 PM UTC

We have our app up and running. To test the HTML to PDF, i copied one of your test pages first tried on local box it did not work then copied on our server same result.

Below is my code, it fails to convert to Image (html.ConvertToImage) fails.

I would appreciate if you could review this and provide solution. Please also do share your working code.

DLL referenced -

Code Snippet -
HtmlConverter html = new HtmlConverter();
System.Drawing.Image _img = html.ConvertToImage(_baseUrl, ImageType.Metafile);//,1248,1024);

if (_img == null)
throw new ApplicationException("Could not generate the report. Please contact the administrator.");

PDFDocument _pdfDoc = new PDFDocument();
_pdfDoc.Compression = CompressionLevel.NoCompression;

IPDFGraphicState _properties = _pdfDoc.CreateGraphicState();
_properties.SplitImages = true;
_properties.BreakBehavior = AutoBreakBehavior.Cropping;

_pdfDoc.LastPage.Margins.All = 0;
SizeF _destSize = new SizeF();

if (_img.Width > _pdfDoc.LastPage.DrawingWidth)
_destSize = new SizeF(_pdfDoc.LastPage.DrawingWidth, -1);
_destSize = _img.Size;

_pdfDoc.LastPage.Graphics.DrawImage(PointF.Empty, _img, _properties);

HttpResponse _response = HttpContext.Current.Response;
_response.AddHeader("Content-Type", "binary/octet-stream");
_pdfDoc.Save("webtopdf.pdf", _response, HttpReadType.Open);


Administrator [Syncfusion]
Replied On March 27, 2008 07:31 AM UTC

Hi siddhartha,

Thank you for your update.

I had created a sample with your code. I got the exception "System.Threading.ThreadStateException". But it can be solved
by including the attribute AspCompat="true" in the @Page directive. Please try to include the attribute and run the sample.

Please refer the video clip:


Please follow the steps below that has to be done under Asp.net environment for converting HTML webpage to PDF document .

1) Include the attribute AspCompat="true" in the @Page directive.

Here is the code snippet

<%@ Page Language="C#" AutoEventWireup="true" AspCompat="true" %>

2) Reference the "AxSHDocVw.dll, SHDocVw.dll" assembly to the project. This dll can be found along with the below sample that shipped with Essential studio.

[Install drive]:\Documents and Settings\Username\My Documents\Syncfusion\ EssentialStudio \version\Windows\Pdf.Windows\ Samples\2.0\HtmlToPdf\CS

3) Place these COM assemblies in the "BIN" directory of your project.

The above steps helps you to resolve the issues you have faced.

please try this and if the problem still exists could you please send us what issue you have reproduced
and also provide the stack trace so that we could give you a better solution?



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

This page will automatically be redirected to the 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