使用ESC指令控制POS机小票Word文件下载.docx

上传人:b****2 文档编号:14311285 上传时间:2022-10-22 格式:DOCX 页数:85 大小:40.54KB
下载 相关 举报
使用ESC指令控制POS机小票Word文件下载.docx_第1页
第1页 / 共85页
使用ESC指令控制POS机小票Word文件下载.docx_第2页
第2页 / 共85页
使用ESC指令控制POS机小票Word文件下载.docx_第3页
第3页 / 共85页
使用ESC指令控制POS机小票Word文件下载.docx_第4页
第4页 / 共85页
使用ESC指令控制POS机小票Word文件下载.docx_第5页
第5页 / 共85页
点击查看更多>>
下载资源
资源描述

使用ESC指令控制POS机小票Word文件下载.docx

《使用ESC指令控制POS机小票Word文件下载.docx》由会员分享,可在线阅读,更多相关《使用ESC指令控制POS机小票Word文件下载.docx(85页珍藏版)》请在冰豆网上搜索。

使用ESC指令控制POS机小票Word文件下载.docx

usingSystem.Management;

usingSystem.IO;

usingLaisonTech.MediaLib;

usingLaisonTech.CommonBLL;

namespaceLaisonTech.MediaLib

{

#region结构体定义

[StructLayout(LayoutKind.Sequential)]

publicstructOVERLAPPED

{

intInternal;

intInternalHigh;

intOffset;

intOffSetHigh;

inthEvent;

};

publicstructPRINTER_DEFAULTS

publicintpDatatype;

publicintpDevMode;

publicintDesiredAccess;

}

///<

summary>

///对齐方式

/summary>

publicenumeTextAlignMode

Left=0,

Middle=1,

Right=2

#endregion

///小票打印类

///使用方法:

///1GetPrinterList获取已经安装的所有打印机列表.

///Open打开指定打印机

///2控制打印机动作、执行打印内容之前,必须先调用StartPrint,准备向打印机发送控制指令

///3调用SetLeft,SetBold,SetAlignMode,SetFontSize......设置打印参数

///4PrintText打印内容.注意:

打印该行内容后会自动换行(本类会在该行内容末尾添加一个换行符)

///PrintImageFile或PrintBitMap打印图片

///5控制指令和打印内容都发送完毕后,调用EndPrint执行真正打印动作

///6退出程序前调用Close

publicclassReceiptHelper

#region指令定义

privatestaticByte[]Const_Init=newbyte[]{0x1B,0x40,

0x20,0x20,0x20,0x0A,

0x1B,0x64,0x10};

//设置左边距

privateconststringConst_SetLeft="

1D4C"

;

//设置粗体

privateconststringConst_SetBold="

1B45"

privateconstStringConst_Bold_YES="

01"

privateconstStringConst_Bold_NO="

00"

//设置对齐方式

privateconststringConst_SetAlign="

1B61"

privateconstStringConst_Align_Left="

30"

privateconstStringConst_Align_Middle="

31"

privateconstStringConst_Align_Right="

32"

//设置字体大小,与SetBigFont不能同时使用

privateconststringConst_SetFontSize="

1D21"

//设置是否大字体,等同于SetFontSize=2

//privateconstStringConst_SetBigFontBold="

1B2138"

//privateconstStringConst_SetBigFontNotBold="

1B2130"

//privateconstStringConst_SetCancelBigFont="

1B2100"

///打印并走纸

privatestaticByte[]Const_Cmd_Print=newbyte[]{0x1B,0x4A,0x00};

//走纸

privateconststringConst_FeedForward="

1B4A"

privateconststringConst_FeedBack="

1B6A"

//切纸

privatestaticByte[]Const_SetCut=newbyte[]{0x1D,0x56,0x30};

//查询打印机状态

privatestaticByte[]Const_QueryID=newbyte[]{0x1D,0x67,0x61};

//回复帧以ID开头

privatestaticStringConst_ResponseQueryID="

ID"

///设置图标的指令

privatestaticByte[]Const_SetImageCommand=newByte[]{0x1B,0x2A,0x21};

#region常量定义

///最大字体大小

publicconstInt32Const_MaxFontSize=8;

///最大走纸距离

publicconstInt32Const_MaxFeedLength=5000;

///最大高宽

publicconstInt32Const_MaxImageLength=480;

///每次通信最多打印的行数

publicconstInt32Const_OncePrintRowCount=24;

publicconstInt32Const_BrightnessGate=100;

///无效句柄

publicconstInt32Const_InvalidHandle=-1;

#endregion

#region私有成员

///打印机句柄

privateintm_Handle=-1;

///是否已经初始化

privateBooleanm_Inited=false;

#region私有函数

[DllImport("

winspool.Drv"

EntryPoint="

OpenPrinterA"

SetLastError=true,CharSet=CharSet.Auto,ExactSpelling=true,CallingConvention=CallingConvention.StdCall)]

publicstaticexternboolOpenPrinter([MarshalAs(UnmanagedType.LPStr)]stringszPrinter,

outInt32hPrinter,IntPtrpd);

StartDocPrinterA"

SetLastError=true,CharSet=CharSet.Ansi,ExactSpelling=true,CallingConvention=CallingConvention.StdCall)]

publicstaticexternboolStartDocPrinter(Int32hPrinter,Int32level,[In,MarshalAs(UnmanagedType.LPStruct)]DOCINFOAdi);

EndDocPrinter"

SetLastError=true,ExactSpelling=true,CallingConvention=CallingConvention.StdCall)]

publicstaticexternboolEndDocPrinter(Int32hPrinter);

StartPagePrinter"

publicstaticexternboolStartPagePrinter(Int32hPrinter);

EndPagePrinter"

publicstaticexternboolEndPagePrinter(Int32hPrinter);

WritePrinter"

publicstaticexternboolWritePrinter(In

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 其它

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1