Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Guys,

I have developed an application for billing purpose and My client is using Thermal Printer for Invoice Billing. My Client has WeB TH400 Thermal Printer and Whenever client go for print he has to follow this path to print

Image1
Image2
Image3
Code as below

C#
ds.Tables.Clear();
           crystalReportViewer1.Refresh();
           try
           {
               adp = new SqlDataAdapter(query, con);
               adp.Fill(ds, "order");
               adp1 = new SqlDataAdapter(query2, con);
               adp1.Fill(ds, "BillDetails");
               ReportDocument rd = new ReportDocument();
               int count = ds.Tables["BillDetails"].Rows.Count;
               if(count < 5)
               {
                   rd.Load(Application.StartupPath + "\\crOrderReport3.rpt");
               }
               else if(count > 10)
               {
                   rd.Load(Application.StartupPath + "\\crOrderReport.rpt");
               }
               else
               {
                   rd.Load(Application.StartupPath + "\\crOrderReport1.rpt");
               }
               rd.SetDataSource(ds.Tables["order"]);
               foreach(ReportObject repOp in rd.ReportDefinition.ReportObjects)
               {
                   if(repOp.Kind == ReportObjectKind.SubreportObject)
                   {
                       string SubRepName = ((SubreportObject) repOp).SubreportName;
                       ReportDocument subRepDoc = rd.Subreports[SubRepName];
                       subRepDoc.SetDataSource(ds.Tables["BillDetails"]);
                   }
               }

               crystalReportViewer1.ToolPanelView = CrystalDecisions.Windows.Forms.ToolPanelViewType.None;


               crystalReportViewer1.ReportSource = rd;

               //crystalReportViewer1.DataBind();
           }
           catch(Exception ex)
           {
               MessageBox.Show("Error occur during Report");
              // MessageBox.Show(ex.Message);
           }

Thank You
Akashkumar
Posted
Updated 24-Jun-15 6:58am
v2
Comments
Sinisa Hajnal 24-Jun-15 1:56am    
What do you mean center the page option? As far as I know the default is left align. Did you change something? If not, right click on the report surface in the designer, select Page Setup and check what options are set. Check also Printer setup afterwards.
Akashkumar1002 24-Jun-15 13:02pm    
Hi Sinisa Hajnal, I have taken a snapshot and provided the link for it also. If you go to link you will get the clear idea. I appreciate your help but I have tried that also.
Sinisa Hajnal 24-Jun-15 16:50pm    
I don't understand, your image (last one) shows the checkbox unchecked. Are you asking how to do it programaticaly?
Akashkumar1002 24-Jun-15 22:22pm    
Yes, Initially it was checked and due to that printer printing first blank then data. User has to always do unchecked the checkbox. I'm not getting any solution. The printer is POS printer (Thermal Printer).
Sinisa Hajnal 25-Jun-15 12:54pm    
You'll have to read the documentation for that specific printer API. Sorry, I cannot help you more then that. Good luck.

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