- Home
- Forum
- ASP.NET Web Forms (Classic)
- HTML - PDF on deployment
HTML - PDF on deployment
Hi,
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
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
SIGN IN To post a reply.
3 Replies
AD
Administrator
Syncfusion Team
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:
http://www.syncfusion.com/Support/user/uploads/webdeploy_8b7da45e.pdf
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.
Regards,
G.Yavana
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:
http://www.syncfusion.com/Support/user/uploads/webdeploy_8b7da45e.pdf
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.
Regards,
G.Yavana
SI
Sid
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 -
AxSHDocVw.dll
SHDocVw.dll
syncfusion.htmlconverter.base.dll
syncfusion.core.dll
syncfusion.pdf.base.dll
syncfusion.pdf.Web.dll
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);
else
_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);
Thanks,
Sid
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 -
AxSHDocVw.dll
SHDocVw.dll
syncfusion.htmlconverter.base.dll
syncfusion.core.dll
syncfusion.pdf.base.dll
syncfusion.pdf.Web.dll
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);
else
_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);
Thanks,
Sid
AD
Administrator
Syncfusion Team
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:
http://websamples.syncfusion.com/samples/Pdfvideoclip.Zip
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
[Aspx]
<%@ 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?
Regards,
G.Yavana
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:
http://websamples.syncfusion.com/samples/Pdfvideoclip.Zip
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
[Aspx]
<%@ 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?
Regards,
G.Yavana
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
SI Sid
- Mar 25, 2008 01:19 PM UTC
- Mar 27, 2008 07:31 AM UTC