Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code and i am getting the result as a byte array.
i want to print this byte array without saving as pdf in the system.
kindly note, this is a web application not a windows application.
Page p = new Page();
    string fname = string.Empty;
    string filetype = string.Empty;

    ReportViewer rptvw1 = new ReportViewer();
    rptvw1.ProcessingMode = ProcessingMode.Local;
    rptvw1.LocalReport.ReportPath = p.Server.MapPath("~/GridReport.rdlc");
    BL_Insurance.PrintDetail print = new BL_Insurance.PrintDetail();
    DataTable ds = print.Print(Convert.ToInt32(p.Session["transactionid"]), Convert.ToString(p.Session["typeofplan"]),             Convert.ToInt32(p.Session["UserID"]));
    ReportDataSource datasource = new ReportDataSource("DataSet1", ds);
    rptvw1.LocalReport.DataSources.Clear();
    rptvw1.LocalReport.DataSources.Add(datasource);
    ReportParameter[] param = new ReportParameter[4];
    param[0] = new ReportParameter("Company", Convert.ToString(p.Session["insurancecompany"]));
    param[1] = new ReportParameter("Policy", Convert.ToString(p.Session["policyname"]));
    if (ds.Columns.Contains("Adult"))
    {
        param[2] = new ReportParameter("Adult", "True");
        param[3] = new ReportParameter("Child", "True");
    }

    else
    {
        param[2] = new ReportParameter("Adult", "False");
        param[3] = new ReportParameter("Child", "False");
    }
    rptvw1.LocalReport.SetParameters(param);
    rptvw1.LocalReport.Refresh();
    Warning[] warnings = null;
    string[] streamIds = null;
    string mimeType = string.Empty;
    string encoding = string.Empty;
    string extension = string.Empty;
    string fileNameExtension;
    filetype = "pdf";
    byte[] bytes = rptvw1.LocalReport.Render(filetype, null, out mimeType, out encoding, out extension, out streamIds, out warnings);
Posted
Updated 19-Apr-14 19:48pm
v3
Comments
Sergey Alexandrovich Kryukov 18-Apr-14 12:00pm    
What do you mean by "print"? What's the problem?
—SA
Rahul VB 20-Apr-14 1:48am    
I have tried to update his question and i hope i conveyed what he meant.
Anto Reegan 19-Apr-14 1:11am    
Hi Thanks for reply.
first i have to convert this byte array to pdf.
next i have to show printer option without display the pdf.
important thing is i should not save the pdf in my machine or server.
i want to print this byte array using window.print() thats it.
Rahul VB 20-Apr-14 1:50am    
Brother, i have updated your question. Please tell me, this is what you meant?
Anto Reegan 21-Apr-14 0:45am    
Ya right Rahul..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900