繁体   English   中英

PrintDocument空白

[英]PrintDocument coming up blank

我有这种方法应该生成我需要打印的内容:

    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;
    }
   e.Graphics.PageUnit = GraphicsUnit.Inch;
   ...
   e.Graphics.DrawString("Choking Hazard", ..., 200, 2);

该字符串将在200英寸处打印。 可以肯定地说,纸张不是那么大,通常是8英寸。 您看不到纸上的内容。 考虑更改PageUnit或使用更小的浮点打印位置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM