首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PrintDocument出现空白

PrintDocument出现空白
EN

Stack Overflow用户
提问于 2013-05-21 03:27:01
回答 1查看 1.2K关注 0票数 1

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

代码语言:javascript
复制
    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中查看它时,它会出现空白。我在这里错过了什么?

顺便说一下,这是我的构造函数:

代码语言:javascript
复制
    public Form1()
    {
        InitializeComponent();
        this.myPrintDocument.PrintPage += new
            System.Drawing.Printing.PrintPageEventHandler
            (this.myPrintDocument_PrintPage);
    }

对于Mark

代码语言:javascript
复制
    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;
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-21 04:38:05

代码语言:javascript
复制
   e.Graphics.PageUnit = GraphicsUnit.Inch;
   ...
   e.Graphics.DrawString("Choking Hazard", ..., 200, 2);

该字符串将以200英寸的速度打印。假设你的论文不是很大,8英寸是典型的。你看不到报纸上有什么。考虑更改PageUnit或使用小得多的浮点打印位置。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16656884

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档