Wednesday, May 9, 2012

Export To PDF

private void ExportToPDF(DataTable pdtblData)
{
byte[] bytFileData = null;
string strfname = Services.IDGenerator.GetUniqueKeyWithPrefix(_strPerfix, 10) + ".pdf";
bytFileData = GeneratePDF(pdtblData);
if(bytFileData != null)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + strfname);
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(bytFileData);
Response.End();
}
else
{
ScriptManager.RegisterStartupScript(UpdatePanel3, UpdatePanel3.GetType(), "scriptEF", "alert('Error Occured')", true);
}
}

No comments: