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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

HtmlToPdf question with FromString method

Thread ID:





88415 Jul 22,2009 11:55 AM UTC Jul 28,2009 11:33 AM UTC ASP.NET Web Forms (Classic) 3
Tags: PDF
Andreas Hirtzel
Asked On July 22, 2009 11:55 AM UTC


I'm fairly new with Sycfusion. I'm looking for a sample for creating Pdf from Html while using the FromString method, but can't found some. How can I use this method and generate a metafile format?

Thiruvenkadam E [Syncfusion]
Replied On July 23, 2009 07:43 AM UTC

Hi Andreas,

Thanks for your interest in Syncfusion products.

Creating Pdf from Html while using the FromString method

We can able to create a pdf form html by using the FormString() method.

Kindly refer the below code snippet which helps to create a Pdf file from Html by using the FromString method.

//Create a new HtmlConverter.
HtmlConverter html = new HtmlConverter();
//Create a new StreamReader
StreamReader reader=new StreamReader(htmlFile);
//Reads the stream.
string htmlText=reader.ReadToEnd();
//Gets the Html file path.
string path = Path.GetFullPath(htmlFile);
//Renders the html into image.
Image result = html.FromString(htmlText, path, ImageType.Metafile, 620, 782, AspectRatio.None)
//Create a pdf metafile
PdfMetafile mf = new PdfMetafile(result as Metafile);
mf.Quality = 100;
PdfLayoutFormat format=new PdfLayoutFormat();
//Draws the meta file.
mf.Draw(page, PointF.Empty,format);

Please do find the sample from the below specified location which demonstrates to Create a Pdf file from Html by using the FromString method and how to create an Metafile from Html.


Please let us know if you need any further information.


Andreas Hirtzel
Replied On July 26, 2009 08:45 PM UTC

Hi Thiru,

works fine. Thank you!

Sri Subhashini M [Syncfusion]
Replied On July 28, 2009 11:33 AM UTC

Hi Andreas,

Glad to hear that it works great. Please let me know if you have any other queries.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon