//===================================================
protected void Page_Load(object sender, EventArgs e)
{
byte[] bytes = null;
string param = Request.QueryString["numAbonnement"];
bytes = afficheReabonnement(param);
exportBytes(bytes);
}
//===================================================
private void exportBytes(byte[] bytes)
{
if (bytes == null)
{
return;
}
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.Buffer = false;
Response.BufferOutput = false;
Response.AddHeader("Accept-Header", bytes.Length.ToString());
Response.AddHeader("Accept-Ranges", "bytes");
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("Content-Length", bytes.Length.ToString());
Response.AddHeader("Content-Disposition", "inline; filename=test.pdf");
Response.ContentType = "application/pdf";
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
//===================================================
private static byte[] generatePDF(DataSet ds)
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
LocalReport report = new LocalReport();
report.DataSources.Add(new ReportDataSource("dsTest", ds.Tables["dtTest"]));
string path = "Test.rdlc";
report.ReportPath = HttpContext.Current.Server.MapPath(path);
report.DisplayName = "name";
byte[] bytes = report.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);
return bytes;
}
Partager