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

Converting an HTML file to PDF (Not getting correct content in pdf )

Hi Team,

                    i am trying to convert my HTML page to PDF. which i have done successfully but i got a problem with the contents of it. i want to search concerned  text after generating it but i used all three methods which was given in the sample examples  but i am unable to do so. Please help.

My code methods are below..

1.   its definitely Generate an Image

           using (System.Drawing.Image img = html.ConvertToImage(sourceUrl, Syncfusion.HtmlConverter.ImageType.Bitmap, (int)width,1500, AspectRatio.KeepWidth))
                    if (img != null)
                        PdfImage image = new PdfBitmap(img);
                        PdfLayoutFormat format = new PdfLayoutFormat();
                        format.Layout = PdfLayoutType.OnePage;
                        if (img.Size.Width > pageSize.Width)
                            image.Draw(page, new RectangleF(0, 0, pageSize.Width, (1500)), format);
                            image.Draw(page, new RectangleF(0, 0, img.Width, (img.Height)), format);
                        Response.Write("Warning ! Please check the HTML link");

2.            using (HtmlToPdfResult result = html.Convert(sourceUrl, Syncfusion.HtmlConverter.ImageType.Metafile, (int)width, (int)height, 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;
                        doc.PageSettings.Height = result.RenderedImage.Size.Height;
                        format.SplitTextLines = true;
                        format.SplitImages = true;
                        result.Render(page, format);

3.         using (HtmlConverter html = new HtmlConverter())
                html.ConvertToTaggedPDF(doc, sourceUrl);

In all above three methods i use my SourceURL to generate PDF files but i got an image attached to that pdf in all these three methods.

i am using .Net, MVC, C# with visual studio 2013.

Sample file attached.

Attachment: 77d70898af954673bfb49ccd156865f1_Sample_8585989.rar

8 Replies

KC Karthikeyan Chandrasekar Syncfusion Team June 4, 2014 12:37 PM UTC

Hi Shobhit,

Thank you for using Syncfusion Products.


On our analysis with the PDF document which you have provided, we have found that the PDF contains Bitmapped image. Html Converter make use of MSHTML (IE Rendering Engine) to convert Web pages to Image, and then convert to PDF. With IE 9 and above there is a known issue that it generates only raster image. You can get more information on this from the following link:



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.

$system drive:\Program Files\Syncfusion\Essential Studio\$Version # \Utilities\PDF\Legacy Drawing


After these changes please try to convert the Html to PDF which will produce the sharper selectable text.




SK shobhit kumar chauhan June 5, 2014 05:10 AM UTC

Thank a Lot sir now its working fine.   :)

KC Karthikeyan Chandrasekar Syncfusion Team June 6, 2014 04:08 AM UTC

Hi Shobhit,

Thank you for update, please let us know if you need any further assistance.




MC Marco Casamento October 22, 2014 11:51 AM UTC

Hi, I've the same problem, see the attached zipped pdf.
I've run the mentioned utility and read the article, but unfortunately I've not been able to solve the issue.

The full code I run is available here: http://share.linqpad.net/9owopm.linq
The machine I'm using is Windows 7 64 with IE11 installed

Any clue ?
Thanks in advance,

Attachment: delmetest_aba39b5b.zip

KC Karthikeyan Chandrasekar Syncfusion Team October 23, 2014 01:31 PM UTC

Hi Macro,

Could you please conform you have run the Legacy tool with elevated permission and make sure that the FEATURE_IVIEWOBJECTDRAW_DMLT9_WITH_GDI at both HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER is set as below?







I have attached the generated PDF document for your reference.





MC Marco Casamento October 27, 2014 09:52 AM UTC

Yes, I'm 100% sure, also adding two snapshots of my system registry by regedit.
I've also restarted the pc, but no luck


MC Marco Casamento October 27, 2014 09:57 AM UTC

Sorry, forgot to add the HKCU in the zip



KC Karthikeyan Chandrasekar Syncfusion Team October 29, 2014 02:16 PM UTC

Hi Marco,

Thank you for your information.


We can able to reproduce this issue, we will fix this issue in our upcoming release.




Live Chat Icon For mobile
Up arrow icon