标题:怎么打印内容是空的?
只看楼主
asad
Rank: 1
等 级:新手上路
威 望:1
帖 子:67
专家分:0
注 册:2019-12-6
结帖率:80%
 问题点数:0 回复次数:5 
怎么打印内容是空的?
private void printDoc_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            printDoc.PrinterSettings.PrinterName = @"\\192.168.135.130\HP LaserJet Professional P1108";   //“打印机名称”;
        }

        private void printDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Graphics MyGraphics = e.Graphics;
            SolidBrush drawBrush = new SolidBrush(Color.Black);
            Font drawFont = new Font("黑体", 10);       //字体 和 大小
            MyGraphics.DrawString("打印内容1", drawFont, drawBrush, 0, 0);
            MyGraphics.DrawString("打印内容2", drawFont, drawBrush,0,100);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.printDoc.PrintPage += new PrintPageEventHandler(this.printDoc_PrintPage);
            printDoc.Print();
        }

[此贴子已经被作者于2022-3-9 10:21编辑过]

搜索更多相关主题的帖子: sender 内容 打印 object new 
2022-03-07 22:33
asad
Rank: 1
等 级:新手上路
威 望:1
帖 子:67
专家分:0
注 册:2019-12-6
得分:0 
Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim g As Graphics = e.Graphics
        'g.DrawRectangle(New Pen(New SolidBrush(Color.Red), 2), New Rectangle(10, 0, 100, 60))
        g.DrawString(s, New Font("黑体", 10), New SolidBrush(Color.Black), New Point(10, 62))
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        PrintDialog1.Document = PrintDocument1
        If PrintDialog1.ShowDialog = DialogResult.OK Then
            PrintDocument1.Print()
        End If
    End Sub

[此贴子已经被作者于2022-3-10 10:51编辑过]

2022-03-07 23:32
qq2889577966
Rank: 4
等 级:业余侠客
威 望:5
帖 子:57
专家分:267
注 册:2021-4-14
得分:0 
以前发的,打印的里面都有,应该比较全了
http://bbs.
全部源码无DLL的坑,收费的只是功能多点、bug少点。代码都差不多

[此贴子已经被作者于2022-3-10 08:12编辑过]

2022-03-10 08:09
asad
Rank: 1
等 级:新手上路
威 望:1
帖 子:67
专家分:0
注 册:2019-12-6
得分:0 
回复 3楼 qq2889577966
谢谢!!
2022-03-10 10:47
asad
Rank: 1
等 级:新手上路
威 望:1
帖 子:67
专家分:0
注 册:2019-12-6
得分:0 
回复 3楼 qq2889577966
MyGraphics.DrawString("打印内容2", drawFont, drawBrush,30,100);
请问这30和100是什么单位,是英寸还是厘米?
2022-03-23 14:37
qq2889577966
Rank: 4
等 级:业余侠客
威 望:5
帖 子:57
专家分:267
注 册:2021-4-14
得分:0 
像素,dpi96下我是这么转换
pf.Paper_Area = new Size(
                    (int)Math.Floor(宽度 * 3.779527559055118),
                    (int)Math.Floor(高度 * 3.779527559055118)
                    );
2022-03-28 08:15



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-508488-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.051285 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved