How to convert Html page to Pdf using asp.net (C#)?

HTML to PDF for using asp.net.

I have simple solution is bellow.

You just use below code and convert HTML to PDF.


protected void Page_Load(object sender, EventArgs e)

{

ArrayList ar_li = new ArrayList();

ar_li.Add(Cache["tester"]);

Cache.Remove("tester");

BinaryFormatter bnr_f = new BinaryFormatter();

MemoryStream mstrm = new MemoryStream();

bnr_f.Serialize(mstrm, ar_li);

CR_visitor_Pass cr_vi = new CR_visitor_Pass();

cr_vi.Load(Server.MapPath("~/CR_visitor_Pass.rpt"));

//MemoryStream oStream;    // using System.IO

//oStream = (MemoryStream) ar_li;

Response.Clear();

Response.Buffer = true;

Response.ContentType = "application/pdf";

Response.BinaryWrite(mstrm.ToArray());

Response.End();

}

About the Author

avatar