我正在尝试在打印到收据打印机/热敏打印机之前获取预览,但是问题是预览显示完整的常规页面,而不是热敏纸页面视图。如何获得热敏纸页面视图而不是普通纸? 我已经尝试了以下代码。
try
{
float x, y, lineOffset;
//Bitmap pbImage = new Bitmap("Images/logo.PNG");
// Instantiate font objects used in printing.
Font printFont = new Font("Microsoft Sans Serif", (float)10, FontStyle.Regular, GraphicsUnit.Point); // Substituted to FontA Font
e.Graphics.PageUnit = GraphicsUnit.Point;
// Draw the bitmap
x = 79;
y = 10;
// e.Graphics.DrawImage(pbImage, x, y, pbImage.Width - 13, pbImage.Height - 10);
// Print the receipt text
lineOffset = printFont.GetHeight(e.Graphics) - (float)3.5;
x = 10;
y = 24 + lineOffset;
e.Graphics.DrawString(" TEL 9999-99-9999 C#2", printFont, Brushes.Black, x, y);
y += lineOffset;
e.Graphics.DrawString(" November.23, 2007 PM 4:24", printFont, Brushes.Black, x, y);
y = y + (lineOffset * (float)2.5);
e.Graphics.DrawString("apples $20.00", printFont, Brushes.Black, x, y);
y += lineOffset;
e.Graphics.DrawString("grapes $30.00", printFont, Brushes.Black, x, y);
y += lineOffset;
e.Graphics.DrawString("bananas $40.00", printFont, Brushes.Black, x, y);
printFont = new Font("Microsoft Sans Serif", 20, FontStyle.Regular, GraphicsUnit.Point);
lineOffset = printFont.GetHeight(e.Graphics) - 3;
y += lineOffset;
e.Graphics.DrawString("Total $210.00", printFont, Brushes.Black, x - 1, y);
printFont = new Font("Microsoft Sans Serif", (float)10, FontStyle.Regular, GraphicsUnit.Point);
lineOffset = printFont.GetHeight(e.Graphics);
y = y + lineOffset + 1;
e.Graphics.DrawString("Customer's payment $250.00", printFont, Brushes.Black, x, y);
y += lineOffset;
e.Graphics.DrawString("Change $40.00", printFont, Brushes.Black, x, y - 2);
// Indicate that no more data to print, and the Print Document can now send the print data to the spooler.
e.HasMorePages = false;
}
catch (Exception f)
{
MessageBox.Show(f.Message);
}
而且我还必须打印一个图像徽标,该徽标不能打印,并且参数无效。