Creating a PDF Manually from ReportViewer Output

Sksamantaray
Posted by Sksamantaray under ASP.NET category on | Points: 40 | Views : 3013
1.Render your report in Page_Load first
2.Then in ImageButton Click call createPDFReport() Method.

public void createPDFReport()

{

Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
byte[] bytes = this.ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);

FileStream fs = new FileStream(@"c:\filename.pdf", FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
}

//Pdf image button
protected void Button1_Click1(object sender, EventArgs e)

{

createPDFReport();

}

Comments or Responses

Login to post response