我正在开发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)
{
}
}
感谢您提供任何宝贵的帮助。