ESCP 打印指令使用.docx

  1. 1、本文档共9页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
ESCP 打印指令使用

ESC/P 打印指令使用,3种票据打印方法/blog/c# 知识 2009-02-11 18:11:52 阅读495 评论0 ??字号:大中小?订阅 (1)自定义纸张设置 控制面板-打印机和传真-右键-服务器属性-创建新的格式(2)自定义纸张使用?this.printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize(NewPrint, iWidth, iHeight); NewPrint:制定一纸张名称。? iWidth:纸张使用宽度。? iHeight:纸张使用高度。 iWidth,iHeight 可以在使用过程中调整。 例如:iWidth=923,iHeight=480(3)ESC/P指令使用using System;using System.Runtime.InteropServices;using System.Data;using System.IO;using System.Windows.Forms;namespace PrintDome{ class ClsPrintLPT { private IntPtr iHandle; private FileStream fs; private StreamWriter sw; private string prnPort = LPT1;?? //打印机端口 public ClsPrintLPT() { } private const uint GENERIC_READ = 0 private const uint GENERIC_WRITE = 0 private const int OPEN_EXISTING = 3; /// summary /// 打开一个vxd(设备) /// /summary [DllImport(kernel32.dll, EntryPoint = CreateFile, CharSet = CharSet.Auto)] private static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess, int dwShareMode, int lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, int hTemplateFile); /// summary /// 开始连接打印机 /// /summary private bool PrintOpen() { iHandle = CreateFile(prnPort, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); if (iHandle.ToInt32() == -1) { MessageBox.Show(没有连接打印机或者打印机端口不是LPT1!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } else { fs = new FileStream(iHandle, FileAccess.ReadWrite); sw = new StreamWriter(fs, System.Text.Encoding.Default);?? //写数据 return true; } } /// summary /// 打印字符串 /// /summary /// param name=str要打印的字符串/param private void PrintLine(string str) { sw.WriteLine(str); ; } /// summary /// 关闭打印连接 /// /summary private void PrintEnd() { sw.Close(); fs.Close(); } /// summary /// 打印票据 /// /summary /// param name=dstb_Temp 全部字段数据集合/param /// returnstrue:打印成功 false:打印失败/returns public bool PrintDataSet(DataSet dsPrint) { try { if (PrintOpen()) { PrintLine( ); PrintLine([XXXXXXXXXXXXXXXXXX超市]); PrintLine(NO :????? + dsPrin

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档