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.

HtmlToPdf question with FromString method

Thread ID:

Created:

Updated:

Platform:

Replies:

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

Hi,

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 03:43 AM

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();
format.Layout=PdfLayoutType.Paginate;
//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.

http://files.syncfusion.com/support/pdf.Windows/F88415/HtmlToPdf.zip

Please let us know if you need any further information.

Regards,
Thiru

Andreas Hirtzel
Replied On July 26, 2009 04:45 PM

Hi Thiru,

works fine. Thank you!

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


Hi Andreas,

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

Regards,
Suba

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.

;