body part
download itextsharp.dll
some necessary name space are
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
using iTextSharp.text.html.simpleparser;
using System.IO;
using System.Text;
.cs part
protected void Button2_Click1(object sender, EventArgs e)
{
//SIMPLE TEXT IS CONVERTING
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Filename.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
//Render PlaceHolder to temporary stream
System.IO.StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
PlaceholderPdf.RenderControl(htmlWrite);
StringReader reader = new StringReader(stringWrite.ToString());
//Create PDF document
Document doc = new Document(PageSize.A4);
HTMLWorker parser = new HTMLWorker(doc);
PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Open();
try
{
//Create a footer that will display page number
//Parse Html
parser.Parse(reader);
}
catch (Exception ex)
{
//Display parser errors in PDF.
//Parser errors will also be wisible in Debug.Output window in VS
Paragraph paragraph = new Paragraph("Error! " + ex.Message);
Chunk text = paragraph.Chunks[0] as Chunk;
if (text != null)
{
}
doc.Add(paragraph);
}
finally
{
doc.Close();
}
}
public override void VerifyRenderingInServerForm(Control control)
{
}
try this and let me know