Error on converting HTML to PDF
Hi all,
I made an windows service that convert html to pdf like this:
PDFDocument doc = new PDFDocument();
doc.Compression = CompressionLevel.Best;
IPDFGraphicState properties = doc.CreateGraphicState();
properties.SplitImages = true;
properties.BreakBehavior = AutoBreakBehavior.Cropping;
HtmlConverter html = new HtmlConverter();
PointF imageLocation = new PointF(10, y);
Image infoImg = html.ConvertToImage(infoPath, ImageType.Metafile,800);
SizeF imageSize = new SizeF();
if (infoImg != null)
{
if (infoImg.Width > doc.LastPage.DrawingWidth)
{
imageSize = new SizeF(doc.LastPage.DrawingWidth, infoImg.Height);
}
else
{
imageSize = new SizeF(infoImg.Width, infoImg.Height);
}
y = infoImg.Height;
doc.LastPage.Graphics.DrawImage(imageLocation, infoImg, imageSize, properties);
}
On my computer where I have installed Syncfusion and Visual Studio 2005 works fine, but when I move it on the server that have only installed .Net Framework 2.0 and Syncfusion assemblies registered to GAC (syncfusion.htmlui.base.dll, syncfusion.htmlui.windows.dll, syncfusion.compression.base.dll, syncfusion.htmltodls.base.dll, syncfusion.htmlconverter.base.dll, Syncfusion.dls.base.dll, Syncfusion.pdf.windows.dll, Syncfusion.pdf.base.dll, Syncfusion.Schedule.Windows.dll) give the following errors:
System.ArgumentException: Parameter is not valid. at System.Drawing.Image.get_Width() when I try to get the with of the image I suppose
and
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(Stream stream, ImageFormat format)
at Syncfusion.Pdf.Implementation.Objects.PDFGraphics.GetMetafileSize(Metafile metaFile)
at Syncfusion.Pdf.Implementation.Objects.PDFGraphics.DrawMetafileImage(PointF location, IPDFImage image, SizeF destination, IPDFGraphicState properties, RectangleF clipRectangle)
at Syncfusion.Pdf.Implementation.Objects.PDFGraphics.DrawImage(PointF location, IPDFImage image, SizeF destination, IPDFGraphicState properties, RectangleF clipRectangle)
at Syncfusion.Pdf.Implementation.Objects.PDFGraphics.DrawImage(PointF location, Image image, SizeF destination, IPDFGraphicState properties, RectangleF clipRectangle)
at Syncfusion.Pdf.Implementation.Objects.PDFGraphics.DrawImage(PointF location, Image image, SizeF destination, IPDFGraphicState properties)
when I try to draw image into pdf (last line of code).
Can someone help me? There are other assemblies to add to GAC or?
Thank you,
Irina.
I made an windows service that convert html to pdf like this:
PDFDocument doc = new PDFDocument();
doc.Compression = CompressionLevel.Best;
IPDFGraphicState properties = doc.CreateGraphicState();
properties.SplitImages = true;
properties.BreakBehavior = AutoBreakBehavior.Cropping;
HtmlConverter html = new HtmlConverter();
PointF imageLocation = new PointF(10, y);
Image infoImg = html.ConvertToImage(infoPath, ImageType.Metafile,800);
SizeF imageSize = new SizeF();
if (infoImg != null)
{
if (infoImg.Width > doc.LastPage.DrawingWidth)
{
imageSize = new SizeF(doc.LastPage.DrawingWidth, infoImg.Height);
}
else
{
imageSize = new SizeF(infoImg.Width, infoImg.Height);
}
y = infoImg.Height;
doc.LastPage.Graphics.DrawImage(imageLocation, infoImg, imageSize, properties);
}
On my computer where I have installed Syncfusion and Visual Studio 2005 works fine, but when I move it on the server that have only installed .Net Framework 2.0 and Syncfusion assemblies registered to GAC (syncfusion.htmlui.base.dll, syncfusion.htmlui.windows.dll, syncfusion.compression.base.dll, syncfusion.htmltodls.base.dll, syncfusion.htmlconverter.base.dll, Syncfusion.dls.base.dll, Syncfusion.pdf.windows.dll, Syncfusion.pdf.base.dll, Syncfusion.Schedule.Windows.dll) give the following errors:
System.ArgumentException: Parameter is not valid. at System.Drawing.Image.get_Width() when I try to get the with of the image I suppose
and
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(Stream stream, ImageFormat format)
at Syncfusion.Pdf.Implementation.Objects.PDFGraphics.GetMetafileSize(Metafile metaFile)
at Syncfusion.Pdf.Implementation.Objects.PDFGraphics.DrawMetafileImage(PointF location, IPDFImage image, SizeF destination, IPDFGraphicState properties, RectangleF clipRectangle)
at Syncfusion.Pdf.Implementation.Objects.PDFGraphics.DrawImage(PointF location, IPDFImage image, SizeF destination, IPDFGraphicState properties, RectangleF clipRectangle)
at Syncfusion.Pdf.Implementation.Objects.PDFGraphics.DrawImage(PointF location, Image image, SizeF destination, IPDFGraphicState properties, RectangleF clipRectangle)
at Syncfusion.Pdf.Implementation.Objects.PDFGraphics.DrawImage(PointF location, Image image, SizeF destination, IPDFGraphicState properties)
when I try to draw image into pdf (last line of code).
Can someone help me? There are other assemblies to add to GAC or?
Thank you,
Irina.
SIGN IN To post a reply.
1 Reply
MW
Melba Winshia
Syncfusion Team
August 30, 2007 01:01 PM UTC
Hi Irina,
Thank you for your interest in Essential PDF.
In addition to the assemblies that you have mentioned above, you also need to add the below Interop assemblies.
* SHDocVw.dll
* AxSHDocVw.dll
These assemblies are found in the below location of your system.
C:\Documents and Settings\{user}\My Documents\Syncfusion\EssentialStudio\5.1.0.51\Windows\Pdf.Windows\Samples\2.0\Data\Interop Assemblies
And also, please refer the below link for more details.
http://www.syncfusion.com/products/pdf/windows/Articles/Html_To_PDF.aspx
Please try adding the above assemblies and let me know if the issue still exists.
Thanks,
Melba
Thank you for your interest in Essential PDF.
In addition to the assemblies that you have mentioned above, you also need to add the below Interop assemblies.
* SHDocVw.dll
* AxSHDocVw.dll
These assemblies are found in the below location of your system.
C:\Documents and Settings\{user}\My Documents\Syncfusion\EssentialStudio\5.1.0.51\Windows\Pdf.Windows\Samples\2.0\Data\Interop Assemblies
And also, please refer the below link for more details.
http://www.syncfusion.com/products/pdf/windows/Articles/Html_To_PDF.aspx
Please try adding the above assemblies and let me know if the issue still exists.
Thanks,
Melba
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
IR Irina
- Aug 29, 2007 07:28 AM UTC
- Aug 30, 2007 01:01 PM UTC