我有下一个代码,用于创建一个包含datagridview数据的打印页面。
Font print10B = new Font("Lucida Console", 10, FontStyle.Bold);
Font print8B = new Font("Arial", 9, FontStyle.Regular);
Font print6B = new Font("Arial", 8, FontStyle.Regular);
e.Graphics.DrawString(" NOTA DE PLATA",print10B,Brushes.Black,10,10);
e.Graphics.DrawString("-----------------------------------------", new Font(dataGridView1.Font.FontFamily, 8, FontStyle.Regular), Brushes.Black, 10, 70);
e.Graphics.DrawString("Produs | Cant | Pret | Total ", print8B, Brushes.Black, 10, 100);
int height = 0;
int x = 10;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["DenumireProdus"].Value.ToString(), print6B, Brushes.Black, x, 120+height);
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["produs_cantitate"].Value.ToString(), print6B, Brushes.Black, x+70, 120 + height);
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["produs_pret"].Value.ToString() , print6B, Brushes.Black, x+105, 120 + height);
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["produsvaloare"].Value.ToString(), print6B, Brushes.Black, x + 135, 120 + height);
height += 20;
}
e.Graphics.DrawString("-----------------------------------------", new Font(dataGridView1.Font.FontFamily, 8, FontStyle.Regular), Brushes.Black, 10, dataGridView1.Height);
e.Graphics.DrawString("Total: " + textBox1.Text+" RON", print10B, Brushes.Black,40, dataGridView1.Height + 10);
直到这里:
e.Graphics.DrawString("-----------------------------------------", new Font(dataGridView1.Font.FontFamily, 8, FontStyle.Regular), Brushes.Black, 10, dataGridView1.Height);
e.Graphics.DrawString("Total: " + textBox1.Text+" RON", print10B, Brushes.Black,40, dataGridView1.Height + 10);
打印机不打印上述部分(最后2个拉绳)。为什么?
打印机页面尺寸为比例A4(48mmx68mm)