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.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

110688 Aug 21,2013 04:18 AM Aug 23,2013 03:33 AM ASP.NET Web Forms (Classic) 1
loading
Tags: PDF
Lee K
Asked On August 21, 2013 04:18 AM

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

KarthikeyanC [Syncfusion]
Replied On August 23, 2013 03:33 AM

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


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.

;