Tuesday, July 26, 2011

C# code to Convert BYTE to PDF

I have called this C# snippet on Button Click, You can customized as your need. 


protected void Button1_Click(object sender, EventArgs e)
{
byte[] a = encoding.GetBytes(strHTML);
MemoryStream m = new MemoryStream(a);
Response.Clear();
Response.AddHeader("Content-Length", a.Length.ToString());
Response.ContentType = "application/pdf";
Response.AddHeader("Expires", "0");
Response.AddHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
Response.AddHeader("Pragma","public");
Response.AddHeader("Content-Disposition", "attachment; filename=sample.pdf");
Response.BinaryWrite(a);
Response.Flush();
Response.End();

}


If you find useful kindly leave a comment.

No comments:

Post a Comment