try
{
// Create a Document object
Document document = new Document(PageSize.A4, 0, 0, 0, 0);
DataTable dt = new DataTable();
dt = BLL.GetInstance.GetValuesFromDataBase();
dt.AcceptChanges();
ReportDataSource rds = new ReportDataSource("DataSet1", dt);
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Report1.rdlc")
ReportViewer1.LocalReport.DataSources.Add(rds);
// Create a new PdfWrite object, writing the output to a MemoryStream
var output = new MemoryStream();
var writer = PdfWriter.GetInstance(document, output);
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
byte[] bytes = null;
bytes = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=" + "LabelsforIMCB-" + JobID + "." + extension);
Response.BinaryWrite(bytes); // create the file
Response.Flush(); // send it to the client to download
//Response.ClearContent();
//Response.ClearHeaders();
Response.End();
}
catch (Exception ex){}
No comments:
Post a Comment