热敏打印机不打印大于A4页的文本

问题描述 投票:0回答:1

我正在开发POS应用程序,必须打印到收据打印机。热敏打印机代码无法打印长条收据(大于A4纸张尺寸)。它跳过其余文本。

这里是我在printDocument事件处理程序中使用的代码。

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
        try
        {

                int CurrentX = 5;
                int CurrentY = GetHeight(2);
                int offset = 10;

                //========================Actual Cart is printed here=========
                for (int k = 0; k < grdSalesInvoice.Rows.Count; k++)
                {

                    //I have 45 items to print, but it only shows 35 items in print and also skips footer

                    e.Graphics.DrawString(grdSalesInvoice.Rows[k].Cells["SaleRate"].Value.ToString(), new Font("Arial", 6, FontStyle.Bold), Brushes.Black, new Point(130, CurrentY + offset));
                    e.Graphics.DrawString(grdSalesInvoice.Rows[k].Cells["Quantity"].Value.ToString(), new Font("Arial", 6, FontStyle.Bold), Brushes.Black, new Point(170, CurrentY + offset));
                    e.Graphics.DrawString(grdSalesInvoice.Rows[k].Cells["Discount"].Value.ToString(), new Font("Arial", 6, FontStyle.Bold), Brushes.Black, new Point(210, CurrentY + offset));
                    e.Graphics.DrawString(grdSalesInvoice.Rows[k].Cells["Amount"].Value.ToString(), new Font("Arial", 6, FontStyle.Bold), Brushes.Black, new Point(230, CurrentY + offset));

                    CurrentY = CurrentY + initialOffset;

                }

                Cureen_Height = CurrentY;
                e.Graphics.DrawString("__________________________________________________________________________________", new Font("Arial", 5, FontStyle.Bold), Brushes.Black, new Point(5, GetHeight(3)));

            e.Graphics.DrawString("Footer", new Font("Arial", 7, FontStyle.Bold), Brushes.Black, new Point(224, GetHeight(0)));

        }
        catch (Exception ex)
        {

        }
    }

感谢您提供任何宝贵的帮助。

c# .net printing thermal-printer receipt
1个回答
0
投票

嗯,花了很多时间后,终于得到了我的问题的答案。步骤1:转到设备和打印机Setp2:选择您的打印机,然后单击管理。步骤3:点击打印机属性选项。步骤4:点击“偏好设置”按钮步骤5:点击“高级”按钮步骤6:在纸张尺寸下拉列表中,选择3276mm的长度。

附加信息:3276毫米等于11张A4纸的页面长度,如果您的文本仍大于11页,则必须定义长度甚至大于3276的自定义纸张尺寸。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.