我有这个方法应该生成我需要打印的内容:
private void myPrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.PageUnit = GraphicsUnit.Inch;
e.Graphics.DrawImage(makeBarcode(), 500, 1000);
e.Graphics.DrawString("Do Not Seperate", makeFont(), Brushes.Black, 100, 2);
e.Graphics.DrawString("Choking Hazard", makeFont(), Brushes.Black, 200, 2);
}
但是,当我打印它时,它会出现空白,而当我在 PrintPreviewDialog 中查看它时,它会出现毯子。我在这里缺少什么?
顺便说一下,这是我的构造函数:
public Form1()
{
InitializeComponent();
this.myPrintDocument.PrintPage += new
System.Drawing.Printing.PrintPageEventHandler
(this.myPrintDocument_PrintPage);
}
对于马克
private Image makeBarcode()
{
InventoryBLL ibll = new InventoryBLL();
Barcode b = new Barcode();
b.IncludeLabel = true;
b.Height = 35;
b.Width = 200;
b.BackColor = Color.White;
b.ForeColor = Color.Black;
b.Alignment = BarcodeLib.AlignmentPositions.CENTER;
return b.Encode(TYPE.CODE128, ibll.getFNSKU(txtASIN.Text));
}
private Font makeFont()
{
Font myFont = new Font("arial", 10);
return myFont;
}