Posted on: 6/5/2008 6:18:31 PM | Views : 736

I have used the following code after adding the itext.dll in the bin folder
//Get the HTML from GridView1 StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); GridView1.RenderControl(htw); string html = "&lt;html><body>" + sw.ToString() + "&lt;/body></html>"; //Set up the response Response.Clear(); Response.ContentType = "application/pdf"; //Create pdf document Document document = new Document(PageSize.A4, 80, 50, 30, 65); //Create pdf writer, output directly to OutputStream PdfWriter writer = PdfWriter.GetInstance(document, Response.OutputStream); document.Open(); //Create tempfile to hold the HTML: string tempFile = Path.GetTempFileName(); using (StreamWriter tempwriter = new StreamWriter(tempFile, false)) { tempwriter.Write(html); } //Parse the HTML into the document HtmlParser.Parse(document, tempFile); //Clean ...

Go to the complete details ...