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. Image for the cookie policy date

The text and images got cut off when converting html to pdf

Hello Syncfusion Team,
I encountered a problem when converting html to pdf. The text and image got cut off
The code snippet I was using:
 private void ConvertProcess()
        {
            SizeF pageSize = page.GetClientSize();
            PdfUnitConvertor convertor = new PdfUnitConvertor();
            float width = convertor.ConvertToPixels(page.GetClientSize().Width, PdfGraphicsUnit.Pixel);
            using (HtmlConverter html = new HtmlConverter())
            {
                html.EnableJavaScript = this.enableJS;
                html.AutoDetectPageBreak = this.autoDetectPageBreak;
                html.EnableHyperlinks = this.enableHyperlinks;
                try
                {
                    if (this.isMetaFile)
                    {
                        HtmlToPdfResult result = html.Convert(this.url, Syncfusion.HtmlConverter.ImageType.Metafile, (int)width, -1, AspectRatio.KeepWidth);
                        if (result != null)
                        {
                            PdfMetafile mf = new PdfMetafile(result.RenderedImage as Metafile);
                            mf.Quality = 100;
                            PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
                            format.Break = PdfLayoutBreakType.FitPage;
                            format.Layout = PdfLayoutType.Paginate;
                            this.doc.PageSettings.Height = result.RenderedImage.Size.Height + 1200;
                            format.SplitTextLines = false;
                            format.SplitImages = false;
                            result.Render(page, format);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.ToString());
                }
            }
        }
Could you please help me to correct it?. Appreciate your response.
Thanks in advance,
Lee K


PdfErrors_8d38e070.rar

1 Reply

KC Karthikeyan Chandrasekar Syncfusion Team August 23, 2013 07:33 AM UTC

Hi Lee,

Thank you for your interest in Syncfusion products.

 

Could you please check if you have Internet Explorer version 9 installed in your machine? HtmlConverter makes use of MSHTML (IE rendering engine) to convert the webpage to image. With IE 9 there is a known issue that it generates only raster image which when drawn in PDF appears blurry and splitting could not be done properly. You can get more information on this from the following link:

http://msdn.microsoft.com/en-us/library/ee330732(v=vs.85).aspx#iviewobject_draw

 

As explained, to solve this, the key FEATURE_IVIEWOBJECTDRAW_DMLT9_WITH_GDI should be updated in the registry. Please run the utility placed in the following location to perform the above changes automatically.

Legacy Drawing.zip

 

Please try this and let me know if you have any questions.

 

Thanks,

Karthikeyan.C


Loader.
Live Chat Icon For mobile
Up arrow icon