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.
Unfortunately, activation email could not send to your email. Please try again.

Error on converting HTML to PDF

Thread ID:

Created:

Updated:

Platform:

Replies:

67726 Aug 29,2007 03:28 AM Aug 30,2007 09:01 AM Windows Forms 1
loading
Tags: PDF
Irina
Asked On August 29, 2007 03:28 AM

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.

Melba Winshia [Syncfusion]
Replied On August 30, 2007 09:01 AM

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


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.

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.

;