Search code examples
c#printingcrystal-reportsreport

Blank space at the top of the thermal printer on bills


I'm trying to create a KOT for my POS application, everything works fine, but for some reason, there is a weird space at the top of the bill, this space size is fixed 15 cm, if I printed the report from the Main Report View using visual studio without running the application it's printed normally without spaces, but if I tried to print it from the running application I always get the 15 cm blank space at the top, I tried to print a bill from a different application that I build before its print normally. I tried different ways while searching online but I couldn't fix the problem.

I'm using this code to print the bill:

            KOT Rtp = new KOT();
        if (Rtp.DataDefinition.ParameterFields.Count > 0)
        {
            foreach (ParameterFieldDefinition crDef in Rtp.DataDefinition.ParameterFields)
            {
                if (crDef.ReportName == string.Empty)
                {
                    object objValue = "16";
                    Rtp.SetParameterValue(crDef.ParameterFieldName, objValue);
                }
            }
        }

        ConnectionInfo crConn = new ConnectionInfo();
        crConn.ServerName = Properties.Settings.Default.server;
        crConn.DatabaseName = Properties.Settings.Default.database;
        crConn.UserID = Properties.Settings.Default.user;
        crConn.Password = Properties.Settings.Default.password;
        // get the Report Tables
        Tables crTables = Rtp.Database.Tables;

        // get the Report Tables
        _ = Rtp.Database.Tables;
        for (int i = 0; i < crTables.Count; i++)
        {
            Table crTable = crTables[i];
            TableLogOnInfo tblInfo = crTable.LogOnInfo;
            tblInfo.ConnectionInfo = crConn;
            crTable.ApplyLogOnInfo(tblInfo);
        }
        // then display the Report - here I am using a Crystal Reports Viewer in a Windows Form
        //var frm = new Form1();
        //frm.CrystalReportViewer1.ReportSource = Rtp;
        //frm.ShowDialog();

        CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions popt = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions();
        popt.PrinterName = "SGT-88IV Printer(2)";
        Rtp.ReportClientDocument.PrintOutputController.PrintReport(popt);

here is the bill I get when printing it from the application :

enter image description here

and here is the bill I get when printing it from Main Report Preview in visuals studio : enter image description here

and here is my page setup: enter image description here


Solution

  • I solved my problem by going to the printer settings and change the paper size in advanced options from Printer 80 (72mmx800mm) to Printer 80 (72mmx210mm). enter image description here