C# 打印文档时出现空白
我有这个方法,可以生成我需要打印的内容:C# 打印文档时出现空白,c#,winforms,printing,printdocument,C#,Winforms,Printing,Printdocument,我有这个方法,可以生成我需要打印的内容: private void myPrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.PageUnit = GraphicsUnit.Inch; e.Graphics.DrawImage(makeBarcode(), 500, 1000); e.Gra
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;
}
那根线的打印长度是200英寸。假设你的论文没有那么大,8英寸是比较典型的。你看不到纸上写着什么。考虑改变分页单元或使用更小的浮点打印位置。< /P>
那根线的打印长度是200英寸。假设你的论文没有那么大,8英寸是比较典型的。你看不到纸上写着什么。考虑改变Page单元或使用更小的浮点打印位置。你需要显示你的Maug字体和你的制作条形码的方法。你查看了<代码> E.MangInLink()/Case>并确保你在页面内绘图吗?@ MalkHurl我添加了这两种方法。你试过调用<代码> E.Casic?FrHuSE()?您需要显示您的makeFont和makebarcode方法。您是否查看了
e.MarginBounds()
,并确保您在页面内绘图?@MarkHall我添加了这两种方法。您是否尝试调用e.Graphics.Flush()
?
e.Graphics.PageUnit = GraphicsUnit.Inch;
...
e.Graphics.DrawString("Choking Hazard", ..., 200, 2);