HtmlToPdf question with FromString method

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?

3 Replies

TE Thiruvenkadam E Syncfusion Team 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();
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


AH Andreas Hirtzel July 26, 2009 08:45 PM UTC

Hi Thiru,

works fine. Thank you!


SS Sri Subhashini M Syncfusion Team 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.

Regards,
Suba

Loader.
Up arrow icon