c# winform 写的打印方法,调用惠普打印机没问题,热敏pos80小票机不行

.Net技术 码拜 8年前 (2016-02-28) 2351次浏览
c# winform 写的打印方法,调用惠普打印机没问题,热敏pos80小票机不行.
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Font font = new Font(“宋体”, 14);
Font fonttishi = new Font(“宋体”, 10);
Font fonthm = new Font(“楷体”, 30);
Font fonttitle = new Font(“楷体”, 20);
Brush bru = Brushes.Black;
string strname = label1.Text + textBox1.Text;
string strphone = textBox2.Text;
string strqian = strphone.Substring(0, 4);
string strhou = strphone.Substring(strphone.Length – 2);
string strqihou = strqian + “*****” + strhou;
string strhm = textBox3.Text + “号”;
string strtime = DateTime.Now.ToShortDateString().ToString();
string strtujing = label11.Text;
string strdoc = comboBox1.Text;

StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
e.Graphics.DrawString(“中医馆”, fonttitle, bru, new Rectangle(2, 5, 200, 180),sf);
e.Graphics.DrawString(strhm, fonthm, bru, new Rectangle(2, 45, 350, 180), sf);
e.Graphics.DrawString(strname, font, bru, new Rectangle(2, 120, 700, 200)); // (“x”,”y”,”
宽度”,”高度”)
e.Graphics.DrawString(“手机:” + strqihou, font, bru, new Rectangle(2, 150, 700, 200));
e.Graphics.DrawString(“医生:” + strdoc, font, bru, new Rectangle(2, 180, 700, 200));
e.Graphics.DrawString(“日期:” + strtime, font, bru, new Rectangle(2, 210, 700, 200));
e.Graphics.DrawString(“途径:” + strtujing, font, bru, new Rectangle(2, 240, 700, 200));
e.Graphics.DrawString(“公众号:xxxxxx 可在线挂号”, fonttishi, bru, new Rectangle(2, 270,
700, 200));

}
public void Print()
{
this.pageSetupDialog1.ShowDialog();  //打印设置
this.printPreviewDialog1.ShowDialog(); //打印预览
this.printDocument1.Print();   //打印

}
用的这种方法打印小票,测试的时候用的惠普打印机,没问题,能打出来,当在别的电脑上面用热敏的pos80打印的
时候
就没反应。求帮助,这是为什么。

解决方案

30

直接用个报表控件多好,即方便扩展性又好,例如fastreport。

50

热敏小票,那是小票,巴掌大的,典型的打印纸宽 80mm 有效打印宽度 72mm
new Rectangle(2, 150, 700, 200)    这250,700,200是啥?
A4打印机和热敏小票打印机,是完全不同的,不能混淆。

20

引用 2 楼 pppooo138 的回复:
Quote: 引用 1 楼 homesos 的回复:

直接用个报表控件多好,即方便扩展性又好,例如fastreport。

fastreport 能打印热敏的的pos80吗

只要操作系统认的是打印机设备就可以,你可以下载个fastreport,用它的工具做张报表试一下。


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明c# winform 写的打印方法,调用惠普打印机没问题,热敏pos80小票机不行
喜欢 (0)
[1034331897@qq.com]
分享 (0)