Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. protected void Print_Click(object sender, ImageClickEventArgs e)
  2. {
  3. IolaNetWeightWeb.BarTableAdapters.Product_Weight_Data_Sheet_QueryTableAdapter ds = new IolaNetWeightWeb.BarTableAdapters.Product_Weight_Data_Sheet_QueryTableAdapter();
  4. ReportDataSource rds = new ReportDataSource("Bar_Product_Weight_Data_Sheet_Query", ds.GetData(DropDownList1.Text, DropDownList3.Text));
  5.  
  6. // Variables
  7. Warning[] warnings;
  8. string[] streamIds;
  9. string mimeType = string.Empty;
  10. string encoding = string.Empty;
  11. string extension = string.Empty;
  12.  
  13.  
  14. // Setup the report viewer object and get the array of bytes
  15. ReportViewer viewer = new ReportViewer();
  16. viewer.ProcessingMode = ProcessingMode.Local;
  17. viewer.LocalReport.ReportPath = "printonebartest1.rdlc";
  18. viewer.LocalReport.DataSources.Add(rds); // Add datasource here
  19.  
  20.  
  21. byte[] bytes = ReportViewer1.LocalReport.Render("Pdf", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
  22.  
  23.  
  24. // Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
  25. Response.Buffer = true;
  26. Response.Clear();
  27. Response.ContentType = mimeType;
  28. Response.AddHeader("content-disposition", "inline; filename=PrintOneBar.pdf");
  29. Response.BinaryWrite(bytes); // create the file
  30. Response.Flush(); // send it to the client to download
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement