5939 lines
117 KiB
Markdown
5939 lines
117 KiB
Markdown
# 接口说明文档
|
||
|
||
> 本文档为打印机SDK接口说明文档,涵盖枚举定义、回调接口、端口函数、票据/标签/页模式/黑标打印函数等完整API参考。
|
||
|
||
## 目录
|
||
|
||
- 开发包简介 (第6页)
|
||
|
||
- 常见问题说明 (第7页)
|
||
|
||
- 接口说明 (第8页)
|
||
|
||
- 枚举和宏定义 (第8页)
|
||
|
||
- CP_ComDataBits (第8页)
|
||
|
||
- CP_ComParity (第9页)
|
||
|
||
- CP_ComStopBits (第10页)
|
||
|
||
- CP_ComFlowControl (第11页)
|
||
|
||
- CP_CharacterSet (第12页)
|
||
|
||
- CP_CharacterCodepage (第13页)
|
||
|
||
- CP_MultiByteEncoding (第15页)
|
||
|
||
- CP_ImageBinarizationMethod (第16页)
|
||
|
||
- CP_ImageCompressionMethod (第17页)
|
||
|
||
- CP_ImagePixelsFormat (第18页)
|
||
|
||
- CP_QRCodeECC (第19页)
|
||
|
||
- CP_Pos_Alignment (第20页)
|
||
|
||
- CP_Pos_BarcodeType (第21页)
|
||
|
||
- CP_Pos_BarcodeTextPrintPosition (第22页)
|
||
|
||
- CP_Page_DrawDirection (第23页)
|
||
|
||
- CP_Page_DrawAlignment (第24页)
|
||
|
||
- CP_Label_BarcodeType (第25页)
|
||
|
||
- CP_Label_BarcodeTextPrintPosition (第26页)
|
||
|
||
- CP_Label_Rotation (第27页)
|
||
|
||
- CP_Label_Color (第28页)
|
||
|
||
- CP_PRINTERSTATUS (第29页)
|
||
|
||
- CP_RTSTATUS (第32页)
|
||
|
||
- CP_LABEL_TEXT_STYLE (第34页)
|
||
|
||
- 回调接口 (第35页)
|
||
|
||
- CP_OnNetPrinterDiscovered (第35页)
|
||
|
||
- CP_OnBluetoothDeviceDiscovered (第36页)
|
||
|
||
- CP_OnWiFiP2PDeviceDiscovered (第37页)
|
||
|
||
- CP_OnPortOpenedEvent (第38页)
|
||
|
||
- CP_OnPortOpenFailedEvent (第39页)
|
||
|
||
- CP_OnPortClosedEvent (第40页)
|
||
|
||
- CP_OnPortWrittenEvent (第41页)
|
||
|
||
- CP_OnPortReceivedEvent (第42页)
|
||
|
||
- CP_OnPrinterStatusEvent (第43页)
|
||
|
||
- CP_OnPrinterReceivedEvent (第44页)
|
||
|
||
- CP_OnPrinterPrintedEvent (第45页)
|
||
|
||
- 添加移除回调 (第46页)
|
||
|
||
- CP_Port_AddOnPortOpenedEvent (第46页)
|
||
|
||
- CP_Port_AddOnPortOpenFailedEvent (第47页)
|
||
|
||
- CP_Port_AddOnPortClosedEvent (第48页)
|
||
|
||
- CP_Port_AddOnPortWrittenEvent (第49页)
|
||
|
||
- CP_Port_AddOnPortReceivedEvent (第50页)
|
||
|
||
- CP_Port_RemoveOnPortOpenedEvent (第51页)
|
||
|
||
- CP_Port_RemoveOnPortOpenFailedEvent (第52页)
|
||
|
||
- CP_Port_RemoveOnPortClosedEvent (第53页)
|
||
|
||
- CP_Port_RemoveOnPortWrittenEvent (第54页)
|
||
|
||
- CP_Port_RemoveOnPortReceivedEvent (第55页)
|
||
|
||
- CP_Printer_AddOnPrinterStatusEvent (第56页)
|
||
|
||
- CP_Printer_AddOnPrinterReceivedEvent (第57页)
|
||
|
||
- CP_Printer_AddOnPrinterPrintedEvent (第58页)
|
||
|
||
- CP_Printer_RemoveOnPrinterStatusEvent (第59页)
|
||
|
||
- CP_Printer_RemoveOnPrinterReceivedEvent (第60页)
|
||
|
||
- CP_Printer_RemoveOnPrinterPrintedEvent (第61页)
|
||
|
||
- 端口函数 (第62页)
|
||
|
||
- CP_Port_EnumCom (第62页)
|
||
|
||
- CP_Port_EnumUsb (第63页)
|
||
|
||
- CP_Port_EnumNetPrinter (第64页)
|
||
|
||
- CP_Port_EnumBtDevice (第65页)
|
||
|
||
- CP_Port_EnumBleDevice (第66页)
|
||
|
||
- CP_Port_EnumWiFiP2PDevice (第67页)
|
||
|
||
- CP_Port_OpenCom (第68页)
|
||
|
||
- CP_Port_OpenUsb (第70页)
|
||
|
||
- CP_Port_OpenTcp (第71页)
|
||
|
||
- CP_Port_OpenBtSpp (第72页)
|
||
|
||
- CP_Port_OpenBtBle (第73页)
|
||
|
||
- CP_Port_WiFiP2P_Connect (第74页)
|
||
|
||
- CP_Port_WiFiP2P_Disconnect (第75页)
|
||
|
||
- CP_Port_WiFiP2P_IsConnected (第76页)
|
||
|
||
- CP_Port_Write (第77页)
|
||
|
||
- CP_Port_Read (第78页)
|
||
|
||
- CP_Port_ReadUntilByte (第79页)
|
||
|
||
- CP_Port_Available (第80页)
|
||
|
||
- CP_Port_SkipAvailable (第81页)
|
||
|
||
- CP_Port_IsConnectionValid (第82页)
|
||
|
||
- CP_Port_IsOpened (第83页)
|
||
|
||
- CP_Port_Close (第84页)
|
||
|
||
- 获取打印机信息函数 (第85页)
|
||
|
||
- CP_Printer_GetPrinterResolutionInfo (第85页)
|
||
|
||
- CP_Printer_GetPrinterFirmwareVersion (第86页)
|
||
|
||
- CP_Printer_GetPrinterStatusInfo (第87页)
|
||
|
||
- CP_Printer_GetPrinterReceivedInfo (第88页)
|
||
|
||
- CP_Printer_GetPrinterPrintedInfo (第89页)
|
||
|
||
- CP_Printer_GetPrinterLabelPositionAdjustmentInfo (第90页)
|
||
|
||
- CP_Printer_SetPrinterLabelPositionAdjustmentInfo (第91页)
|
||
|
||
- CP_Printer_ClearPrinterBuffer (第92页)
|
||
|
||
- CP_Printer_ClearPrinterError (第93页)
|
||
|
||
- 票据函数 (第94页)
|
||
|
||
- CP_Pos_QueryRTStatus (第94页)
|
||
|
||
- CP_Pos_QueryPrintResult (第95页)
|
||
|
||
- CP_Pos_KickOutDrawer (第96页)
|
||
|
||
- CP_Pos_Beep (第97页)
|
||
|
||
- CP_Pos_FeedAndHalfCutPaper (第98页)
|
||
|
||
- CP_Pos_FullCutPaper (第99页)
|
||
|
||
- CP_Pos_HalfCutPaper (第100页)
|
||
|
||
- CP_Pos_FeedLine (第101页)
|
||
|
||
- CP_Pos_FeedDot (第102页)
|
||
|
||
- CP_Pos_PrintSelfTestPage (第103页)
|
||
|
||
- CP_Pos_PrintText (第104页)
|
||
|
||
- CP_Pos_PrintTextInUTF8 (第105页)
|
||
|
||
- CP_Pos_PrintTextInGBK (第106页)
|
||
|
||
- CP_Pos_PrintTextInBIG5 (第107页)
|
||
|
||
- CP_Pos_PrintTextInShiftJIS (第108页)
|
||
|
||
- CP_Pos_PrintTextInEUCKR (第109页)
|
||
|
||
- CP_Pos_PrintBarcode (第110页)
|
||
|
||
- CP_Pos_PrintBarcode_Code128Auto (第111页)
|
||
|
||
- CP_Pos_PrintQRCode (第112页)
|
||
|
||
- CP_Pos_PrintQRCodeUseEpsonCmd (第113页)
|
||
|
||
- CP_Pos_PrintQRCodeUseImageCmd (第114页)
|
||
|
||
- CP_Pos_PrintDoubleQRCode (第115页)
|
||
|
||
- CP_Pos_PrintPDF417BarcodeUseEpsonCmd (第116页)
|
||
|
||
- CP_Pos_PrintRasterImageFromFile (第117页)
|
||
|
||
- CP_Pos_PrintRasterImageFromData (第118页)
|
||
|
||
- CP_Pos_PrintRasterImageFromPixels (第119页)
|
||
|
||
- CP_Pos_PrintHorizontalLine (第121页)
|
||
|
||
- CP_Pos_PrintHorizontalLineSpecifyThickness (第122页)
|
||
|
||
- CP_Pos_PrintMultipleHorizontalLinesAtOneRow (第123页)
|
||
|
||
- CP_Pos_ResetPrinter (第124页)
|
||
|
||
- CP_Pos_SetPrintSpeed (第125页)
|
||
|
||
- CP_Pos_SetPrintDensity (第126页)
|
||
|
||
- CP_Pos_SetSingleByteMode (第127页)
|
||
|
||
- CP_Pos_SetCharacterSet (第128页)
|
||
|
||
- CP_Pos_SetCharacterCodepage (第129页)
|
||
|
||
- CP_Pos_SetMultiByteMode (第130页)
|
||
|
||
- CP_Pos_SetMultiByteEncoding (第131页)
|
||
|
||
- CP_Pos_SetMovementUnit (第132页)
|
||
|
||
- CP_Pos_SetPrintAreaLeftMargin (第133页)
|
||
|
||
- CP_Pos_SetPrintAreaWidth (第134页)
|
||
|
||
- CP_Pos_SetHorizontalAbsolutePrintPosition (第135页)
|
||
|
||
- CP_Pos_SetHorizontalRelativePrintPosition (第136页)
|
||
|
||
- CP_Pos_SetVerticalAbsolutePrintPosition (第137页)
|
||
|
||
- CP_Pos_SetVerticalRelativePrintPosition (第138页)
|
||
|
||
- CP_Pos_SetAlignment (第139页)
|
||
|
||
- CP_Pos_SetTextScale (第140页)
|
||
|
||
- CP_Pos_SetAsciiTextFontType (第141页)
|
||
|
||
- CP_Pos_SetTextBold (第142页)
|
||
|
||
- CP_Pos_SetTextUnderline (第143页)
|
||
|
||
- CP_Pos_SetTextUpsideDown (第144页)
|
||
|
||
- CP_Pos_SetTextWhiteOnBlack (第145页)
|
||
|
||
- CP_Pos_SetTextRotate (第146页)
|
||
|
||
- CP_Pos_SetTextLineHeight (第147页)
|
||
|
||
- CP_Pos_SetAsciiTextCharRightSpacing (第148页)
|
||
|
||
- CP_Pos_SetKanjiTextCharSpacing (第149页)
|
||
|
||
- CP_Pos_SetBarcodeUnitWidth (第150页)
|
||
|
||
- CP_Pos_SetBarcodeHeight (第151页)
|
||
|
||
- CP_Pos_SetBarcodeReadableTextFontType (第152页)
|
||
|
||
- CP_Pos_SetBarcodeReadableTextPosition (第153页)
|
||
|
||
- 页模式函数 (第154页)
|
||
|
||
- CP_Page_SelectPageMode (第154页)
|
||
|
||
- CP_Page_SelectPageModeEx (第155页)
|
||
|
||
- CP_Page_ExitPageMode (第156页)
|
||
|
||
- CP_Page_PrintPage (第157页)
|
||
|
||
- CP_Page_ClearPage (第158页)
|
||
|
||
- CP_Page_SetPageArea (第159页)
|
||
|
||
- CP_Page_SetPageDrawDirection (第160页)
|
||
|
||
- CP_Page_DrawRect (第161页)
|
||
|
||
- CP_Page_DrawBox (第162页)
|
||
|
||
- CP_Page_DrawText (第163页)
|
||
|
||
- CP_Page_DrawTextInUTF8 (第164页)
|
||
|
||
- CP_Page_DrawTextInGBK (第165页)
|
||
|
||
- CP_Page_DrawTextInBIG5 (第166页)
|
||
|
||
- CP_Page_DrawTextInShiftJIS (第167页)
|
||
|
||
- CP_Page_DrawTextInEUCKR (第168页)
|
||
|
||
- CP_Page_DrawBarcode (第169页)
|
||
|
||
- CP_Page_DrawQRCode (第170页)
|
||
|
||
- CP_Page_DrawRasterImageFromFile (第171页)
|
||
|
||
- CP_Page_DrawRasterImageFromData (第172页)
|
||
|
||
- CP_Page_DrawRasterImageFromPixels (第173页)
|
||
|
||
- 黑标函数 (第175页)
|
||
|
||
- CP_BlackMark_EnableBlackMarkMode (第175页)
|
||
|
||
- CP_BlackMark_DisableBlackMarkMode (第176页)
|
||
|
||
- CP_BlackMark_SetBlackMarkMaxFindLength (第177页)
|
||
|
||
- CP_BlackMark_FindNextBlackMark (第178页)
|
||
|
||
- CP_BlackMark_SetBlackMarkPaperPrintPosition (第179页)
|
||
|
||
- CP_BlackMark_SetBlackMarkPaperCutPosition (第180页)
|
||
|
||
- CP_BlackMark_FullCutBlackMarkPaper (第181页)
|
||
|
||
- CP_BlackMark_HalfCutBlackMarkPaper (第182页)
|
||
|
||
- 标签函数 (第183页)
|
||
|
||
- CP_Label_EnableLabelMode (第183页)
|
||
|
||
- CP_Label_DisableLabelMode (第184页)
|
||
|
||
- CP_Label_CalibrateLabel (第185页)
|
||
|
||
- CP_Label_FeedLabel (第186页)
|
||
|
||
- CP_Label_BackPaperToPrintPosition (第187页)
|
||
|
||
- CP_Label_FeedPaperToTearPosition (第188页)
|
||
|
||
- CP_Label_PageBegin (第189页)
|
||
|
||
- CP_Label_PagePrint (第190页)
|
||
|
||
- CP_Label_DrawText (第191页)
|
||
|
||
- CP_Label_DrawTextInUTF8 (第192页)
|
||
|
||
- CP_Label_DrawTextInGBK (第193页)
|
||
|
||
- CP_Label_DrawBarcode (第194页)
|
||
|
||
- CP_Label_DrawQRCode (第196页)
|
||
|
||
- CP_Label_DrawPDF417Code (第198页)
|
||
|
||
- CP_Label_DrawImageFromFile (第200页)
|
||
|
||
- CP_Label_DrawImageFromData (第201页)
|
||
|
||
- CP_Label_DrawImageFromPixels (第203页)
|
||
|
||
- CP_Label_DrawLine (第205页)
|
||
|
||
- CP_Label_DrawRect (第206页)
|
||
|
||
- CP_Label_DrawBox (第207页)
|
||
|
||
- 其他函数 (第208页)
|
||
|
||
- CP_Library_Version (第208页)
|
||
|
||
- CP_Proto_QueryBatteryLevel (第209页)
|
||
|
||
- CP_Proto_QuerySerialNumber (第210页)
|
||
|
||
- CP_Proto_SetSystemNameAndSerialNumber (第211页)
|
||
|
||
- CP_Proto_SetBluetoothNameAndPassword (第212页)
|
||
|
||
- CP_Proto_SetPTPBasicParameters (第213页)
|
||
|
||
- CP_Settings_Hardware_SetPrintSpeed (第216页)
|
||
|
||
---
|
||
|
||
## 开发包简介
|
||
|
||
1 开发包带有很多详细的例子,开发之前,请先运行相应的例子测试,测试完全没问题,再考虑开发。
|
||
|
||
2 开发包支持各种打印机,包括但不限于票据打印,标签打印,页模式打印,黑标打印。
|
||
|
||
3 开发包支持自动回传功能,开启该功能需要打印机支持自动回传。
|
||
|
||
4 开发包所有的函数都以CP_作为前缀,避免与别家开发包混淆。
|
||
|
||
5 开发包主要由宏定义,枚举,回调,端口函数,票据打印函数,标签打印函数,页模式打印函数,
|
||
|
||
黑标相关函数组成。
|
||
|
||
端口函数以CP_Port_开头,包括打开端口,关闭端口,读写端口等函数。
|
||
|
||
票据打印函数以CP_Pos_开头,主要封装了各种票据指令,可以打印文本,条码,二维码,图片等
|
||
|
||
标签打印函数以CP_Label_开头,主要封装了标签指令,可以打印文本,条码,二维码,图片等
|
||
|
||
页模式打印函数以CP_Page_开头,主要封装了页模式相关指令,可以打印文本,条码,二维码,图片等
|
||
|
||
黑标相关函数以CP_BlackMark_开头,主要封装了黑标定位相关指令
|
||
|
||
6 一个完整的打印流程是,打开端口,各种打印函数,关闭端口。
|
||
|
||
回调接口,可用可不用,不影响正常打印流程,回调只是用于提示信息。
|
||
|
||
7 开发包的所有函数,都在AutoReplyPrint接口里面,
|
||
|
||
工程代码里面,导入com.caysn.autoreplyprint包,即可调用开发包的所有函数。
|
||
|
||
8 如需混淆,在proguard-rules.pro文件加入以下内容即可
|
||
|
||
-keep class com.sun.** {*;}
|
||
|
||
-keep class com.lvrenyang.** {*;}
|
||
|
||
-keep class com.caysn.autoreplyprint.** {*;}
|
||
|
||
---
|
||
|
||
## 常见问题说明
|
||
|
||
1 怎么分辨我的打印机是什么机型,该用什么函数?
|
||
|
||
要注意看机型,是什么机型,用什么函数,用错了就打印不了,或者会打印乱码
|
||
|
||
放票据纸打印的,就是票据机型,使用CP_Pos_系列函数进行打印
|
||
|
||
放标签纸的,就是标签机型,使用CP_Label_系列函数进行打印
|
||
|
||
有些机器既可以放票据纸打印,也可以放标签纸打印的。可以调用函数,开启或关闭标签模式。
|
||
|
||
最好是咨询卖家,看该用什么例子测试,参考例子来写最省事。
|
||
|
||
2 为什么打印一半关机了?
|
||
|
||
看是不是电源不够,额定电压下,一般是要2A的电源就够了。
|
||
|
||
打印机开机时,指示灯的闪烁一般是不一样的,能很明显的看出来。
|
||
|
||
出现问题,要仔细观察指示灯或声音,这样便于定位问题。
|
||
|
||
3 标签打印完,为什么没有定位到缝隙?
|
||
|
||
看是不是开启了标签模式,标签是否识别到,测试方法是按一下进纸按键,是不是完整的进一张纸
|
||
|
||
---
|
||
|
||
## 接口说明
|
||
|
||
#### CP_ComDataBits
|
||
|
||
枚举和宏定义
|
||
|
||
串口数据位。打开串口时,需要指定数据位,一般为8位数据位。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_ComDataBits_4 = 4;
|
||
public static final int CP_ComDataBits_5 = 5;
|
||
public static final int CP_ComDataBits_6 = 6;
|
||
public static final int CP_ComDataBits_7 = 7;
|
||
public static final int CP_ComDataBits_8 = 8;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_ComParity
|
||
|
||
串口校验位。打开串口时,需要指定校验位,一般是无校验。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_ComParity_NoParity = 0;
|
||
public static final int CP_ComParity_OddParity = 1;
|
||
public static final int CP_ComParity_EvenParity = 2;
|
||
public static final int CP_ComParity_MarkParity = 3;
|
||
public static final int CP_ComParity_SpaceParity = 4;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_ComStopBits
|
||
|
||
串口停止位。打开串口时,需要指定停止位,一般是一位停止位。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_ComStopBits_One = 0;
|
||
public static final int CP_ComStopBits_OnePointFive = 1;
|
||
public static final int CP_ComStopBits_Two = 2;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_ComFlowControl
|
||
|
||
串口流控制。打开串口时,需要指定流控制,一般选无流控或者软件流控。硬件流控需要线连对才能用。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_ComFlowControl_None = 0;
|
||
public static final int CP_ComFlowControl_XonXoff = 1;
|
||
public static final int CP_ComFlowControl_RtsCts = 2;
|
||
public static final int CP_ComFlowControl_DtrDsr = 3;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_CharacterSet
|
||
|
||
单字节模式下的国际字符集。当打印机处于单字节模式下时,设置打印机国际字符集,会改变0x20-0x7F这个区间
|
||
|
||
的部分文字的打印。比如货币符号人命币或美元。具体细节请看打印机指令集部分。当打印机处于多字节模式下时,
|
||
|
||
设置该属性无影响。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_CharacterSet_USA = 0;
|
||
public static final int CP_CharacterSet_FRANCE = 1;
|
||
public static final int CP_CharacterSet_GERMANY = 2;
|
||
public static final int CP_CharacterSet_UK = 3;
|
||
public static final int CP_CharacterSet_DENMARK_I = 4;
|
||
public static final int CP_CharacterSet_SWEDEN = 5;
|
||
public static final int CP_CharacterSet_ITALY = 6;
|
||
public static final int CP_CharacterSet_SPAIN_I = 7;
|
||
public static final int CP_CharacterSet_JAPAN = 8;
|
||
public static final int CP_CharacterSet_NORWAY = 9;
|
||
public static final int CP_CharacterSet_DENMARK_II = 10;
|
||
public static final int CP_CharacterSet_SPAIN_II = 11;
|
||
public static final int CP_CharacterSet_LATIN = 12;
|
||
public static final int CP_CharacterSet_KOREA = 13;
|
||
public static final int CP_CharacterSet_SLOVENIA = 14;
|
||
public static final int CP_CharacterSet_CHINA = 15;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_CharacterCodepage
|
||
|
||
单字节模式下的字符代码页。当打印机处于单字节模式下时,设置打印机字符代码页,会改变0x80-0xFF这个区间
|
||
|
||
的部分文字的打印。具体细节请看打印机指令集部分。当打印机处于多字节模式下时,设置该属性无影响。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_CharacterCodepage_CP437 = 0;
|
||
public static final int CP_CharacterCodepage_KATAKANA = 1;
|
||
public static final int CP_CharacterCodepage_CP850 = 2;
|
||
public static final int CP_CharacterCodepage_CP860 = 3;
|
||
public static final int CP_CharacterCodepage_CP863 = 4;
|
||
public static final int CP_CharacterCodepage_CP865 = 5;
|
||
public static final int CP_CharacterCodepage_WCP1251 = 6;
|
||
public static final int CP_CharacterCodepage_CP866 = 7;
|
||
public static final int CP_CharacterCodepage_MIK = 8;
|
||
public static final int CP_CharacterCodepage_CP755 = 9;
|
||
public static final int CP_CharacterCodepage_IRAN = 10;
|
||
public static final int CP_CharacterCodepage_CP862 = 15;
|
||
public static final int CP_CharacterCodepage_WCP1252 = 16;
|
||
public static final int CP_CharacterCodepage_WCP1253 = 17;
|
||
public static final int CP_CharacterCodepage_CP852 = 18;
|
||
public static final int CP_CharacterCodepage_CP858 = 19;
|
||
public static final int CP_CharacterCodepage_IRAN_II = 20;
|
||
public static final int CP_CharacterCodepage_LATVIAN = 21;
|
||
public static final int CP_CharacterCodepage_CP864 = 22;
|
||
public static final int CP_CharacterCodepage_ISO_8859_1 = 23;
|
||
public static final int CP_CharacterCodepage_CP737 = 24;
|
||
public static final int CP_CharacterCodepage_WCP1257 = 25;
|
||
public static final int CP_CharacterCodepage_THAI = 26;
|
||
public static final int CP_CharacterCodepage_CP720 = 27;
|
||
public static final int CP_CharacterCodepage_CP855 = 28;
|
||
public static final int CP_CharacterCodepage_CP857 = 29;
|
||
public static final int CP_CharacterCodepage_WCP1250 = 30;
|
||
public static final int CP_CharacterCodepage_CP775 = 31;
|
||
public static final int CP_CharacterCodepage_WCP1254 = 32;
|
||
public static final int CP_CharacterCodepage_WCP1255 = 33;
|
||
public static final int CP_CharacterCodepage_WCP1256 = 34;
|
||
public static final int CP_CharacterCodepage_WCP1258 = 35;
|
||
public static final int CP_CharacterCodepage_ISO_8859_2 = 36;
|
||
public static final int CP_CharacterCodepage_ISO_8859_3 = 37;
|
||
public static final int CP_CharacterCodepage_ISO_8859_4 = 38;
|
||
public static final int CP_CharacterCodepage_ISO_8859_5 = 39;
|
||
public static final int CP_CharacterCodepage_ISO_8859_6 = 40;
|
||
public static final int CP_CharacterCodepage_ISO_8859_7 = 41;
|
||
public static final int CP_CharacterCodepage_ISO_8859_8 = 42;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_MultiByteEncoding
|
||
|
||
多字节模式下的字符编码。打印机处于多字节模式下时,收到的打印数据,将按照指定的编码进行打印。比如说,
|
||
|
||
设置打印机为多字节模式,再指定多字节模式下字符编码为 UTF8 编码,应用程序需按照 UTF8 编码发送字符串给
|
||
|
||
打印机,打印机就会将字符串打印出来。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_MultiByteEncoding_GBK = 0;
|
||
public static final int CP_MultiByteEncoding_UTF8 = 1;
|
||
public static final int CP_MultiByteEncoding_BIG5 = 3;
|
||
public static final int CP_MultiByteEncoding_ShiftJIS = 4;
|
||
public static final int CP_MultiByteEncoding_EUCKR = 5;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_ImageBinarizationMethod
|
||
|
||
图像二值化算法。由于打印机只能打印黑白单色位图,打印图像的过程中,如果原图是彩图或灰度图,则需要使用
|
||
|
||
二值化算法,将原图转为单色图。不同的算法有不同的效果。
|
||
|
||
阈值算法适用于图片内容都是文字的。
|
||
|
||
误差扩散法适用于所有的图片,但细看会有毛刺。
|
||
|
||
抖动算法效果不如误差扩散法,不建议使用,仅做兼容性保留。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_ImageBinarizationMethod_Dithering = 0;
|
||
public static final int CP_ImageBinarizationMethod_Thresholding = 1;
|
||
public static final int CP_ImageBinarizationMethod_ErrorDiffusion = 2;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_ImageCompressionMethod
|
||
|
||
图片压缩算法。部分打印机支持使用压缩指令打印图片,提高数据传输效率。具体是否支持需要看实际测试结果才
|
||
|
||
知道。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_ImageCompressionMethod_None = 0;
|
||
public static final int CP_ImageCompressionMethod_Level1 = 1;
|
||
public static final int CP_ImageCompressionMethod_Level2 = 2;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_ImagePixelsFormat
|
||
|
||
图片像素格式。打印图片时,如果是直接传的像素数据打印的,那么数据和格式要对应。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_ImagePixelsFormat_MONO = 1;
|
||
public static final int CP_ImagePixelsFormat_MONOLSB = 2;
|
||
public static final int CP_ImagePixelsFormat_GRAY8 = 3;
|
||
public static final int CP_ImagePixelsFormat_BYTEORDERED_RGB24 = 4;
|
||
public static final int CP_ImagePixelsFormat_BYTEORDERED_BGR24 = 5;
|
||
public static final int CP_ImagePixelsFormat_BYTEORDERED_ARGB32 = 6;
|
||
public static final int CP_ImagePixelsFormat_BYTEORDERED_RGBA32 = 7;
|
||
public static final int CP_ImagePixelsFormat_BYTEORDERED_ABGR32 = 8;
|
||
public static final int CP_ImagePixelsFormat_BYTEORDERED_BGRA32 = 9;
|
||
CP_ImagePixelsFormat_MONO = 1,
|
||
```
|
||
|
||
单色位图,高位在前
|
||
|
||
```java
|
||
CP_ImagePixelsFormat_MONOLSB = 2,
|
||
```
|
||
|
||
单色位图,低位在前
|
||
|
||
```java
|
||
CP_ImagePixelsFormat_GRAY8 = 3,
|
||
```
|
||
|
||
灰度图,每个颜色占一个字节
|
||
|
||
```java
|
||
CP_ImagePixelsFormat_BYTEORDERED_RGB24 = 4,
|
||
```
|
||
|
||
按照字节顺序,R G B每个颜色占一个字节
|
||
|
||
```java
|
||
CP_ImagePixelsFormat_BYTEORDERED_BGR24 = 5,
|
||
```
|
||
|
||
按照字节顺序,B G R每个颜色占一个字节
|
||
|
||
```java
|
||
CP_ImagePixelsFormat_BYTEORDERED_ARGB32 = 6,
|
||
```
|
||
|
||
按照字节顺序,A R G B每个颜色占一个字节
|
||
|
||
```java
|
||
CP_ImagePixelsFormat_BYTEORDERED_RGBA32 = 7,
|
||
```
|
||
|
||
按照字节顺序,R G B A每个颜色占一个字节
|
||
|
||
```java
|
||
CP_ImagePixelsFormat_BYTEORDERED_ABGR32 = 8,
|
||
```
|
||
|
||
按照字节顺序,A B G R每个颜色占一个字节
|
||
|
||
```java
|
||
CP_ImagePixelsFormat_BYTEORDERED_BGRA32 = 9
|
||
```
|
||
|
||
按照字节顺序,B G R A每个颜色占一个字节
|
||
|
||
---
|
||
|
||
#### CP_QRCodeECC
|
||
|
||
二维码纠错等级。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_QRCodeECC_L = 1;
|
||
public static final int CP_QRCodeECC_M = 2;
|
||
public static final int CP_QRCodeECC_Q = 3;
|
||
public static final int CP_QRCodeECC_H = 4;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_Alignment
|
||
|
||
票据模式下打印对齐方式。有左对齐,中对齐,右对齐。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_Pos_Alignment_Left = 0;
|
||
public static final int CP_Pos_Alignment_HCenter = 1;
|
||
public static final int CP_Pos_Alignment_Right = 2;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_BarcodeType
|
||
|
||
票据指令打印条码时,指定条码类型。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_Pos_BarcodeType_UPCA = 0x41;
|
||
public static final int CP_Pos_BarcodeType_UPCE = 0x42;
|
||
public static final int CP_Pos_BarcodeType_EAN13 = 0x43;
|
||
public static final int CP_Pos_BarcodeType_EAN8 = 0x44;
|
||
public static final int CP_Pos_BarcodeType_CODE39 = 0x45;
|
||
public static final int CP_Pos_BarcodeType_ITF = 0x46;
|
||
public static final int CP_Pos_BarcodeType_CODEBAR = 0x47;
|
||
public static final int CP_Pos_BarcodeType_CODE93 = 0x48;
|
||
public static final int CP_Pos_BarcodeType_CODE128 = 0x49;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_BarcodeTextPrintPosition
|
||
|
||
票据指令打印条码时,指定条码文字打印位置。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_Pos_BarcodeTextPrintPosition_None = 0;
|
||
public static final int CP_Pos_BarcodeTextPrintPosition_AboveBarcode = 1;
|
||
public static final int CP_Pos_BarcodeTextPrintPosition_BelowBarcode = 2;
|
||
public static final int CP_Pos_BarcodeTextPrintPosition_AboveAndBelowBarcode = 3;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawDirection
|
||
|
||
页模式下打印时,指定页面绘制方向。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_Page_DrawDirection_LeftToRight = 0;
|
||
public static final int CP_Page_DrawDirection_BottomToTop = 1;
|
||
public static final int CP_Page_DrawDirection_RightToLeft = 2;
|
||
public static final int CP_Page_DrawDirection_TopToBottom = 3;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawAlignment
|
||
|
||
页模式下的相关绘制函数,坐标如果是大于等于零,就是实际坐标。也可以指定为此处的特定值,指定在区域内对
|
||
|
||
齐打印。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_Page_DrawAlignment_Left = -1;
|
||
public static final int CP_Page_DrawAlignment_HCenter = -2;
|
||
public static final int CP_Page_DrawAlignment_Right = -3;
|
||
public static final int CP_Page_DrawAlignment_Top = -1;
|
||
public static final int CP_Page_DrawAlignment_VCenter = -2;
|
||
public static final int CP_Page_DrawAlignment_Bottom = -3;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_BarcodeType
|
||
|
||
标签指令打印条码时,指定条码类型。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_Label_BarcodeType_UPCA = 0;
|
||
public static final int CP_Label_BarcodeType_UPCE = 1;
|
||
public static final int CP_Label_BarcodeType_EAN13 = 2;
|
||
public static final int CP_Label_BarcodeType_EAN8 = 3;
|
||
public static final int CP_Label_BarcodeType_CODE39 = 4;
|
||
public static final int CP_Label_BarcodeType_ITF = 5;
|
||
public static final int CP_Label_BarcodeType_CODEBAR = 6;
|
||
public static final int CP_Label_BarcodeType_CODE93 = 7;
|
||
public static final int CP_Label_BarcodeType_CODE128 = 8;
|
||
public static final int CP_Label_BarcodeType_CODE11 = 9;
|
||
public static final int CP_Label_BarcodeType_MSI = 10;
|
||
public static final int CP_Label_BarcodeType_128M = 11;
|
||
public static final int CP_Label_BarcodeType_EAN128 = 12;
|
||
public static final int CP_Label_BarcodeType_25C = 13;
|
||
public static final int CP_Label_BarcodeType_39C = 14;
|
||
public static final int CP_Label_BarcodeType_39 = 15;
|
||
public static final int CP_Label_BarcodeType_EAN13PLUS2 = 16;
|
||
public static final int CP_Label_BarcodeType_EAN13PLUS5 = 17;
|
||
public static final int CP_Label_BarcodeType_EAN8PLUS2 = 18;
|
||
public static final int CP_Label_BarcodeType_EAN8PLUS5 = 19;
|
||
public static final int CP_Label_BarcodeType_POST = 20;
|
||
public static final int CP_Label_BarcodeType_UPCAPLUS2 = 21;
|
||
public static final int CP_Label_BarcodeType_UPCAPLUS5 = 22;
|
||
public static final int CP_Label_BarcodeType_UPCEPLUS2 = 23;
|
||
public static final int CP_Label_BarcodeType_UPCEPLUS5 = 24;
|
||
public static final int CP_Label_BarcodeType_CPOST = 25;
|
||
public static final int CP_Label_BarcodeType_MSIC = 26;
|
||
public static final int CP_Label_BarcodeType_PLESSEY = 27;
|
||
public static final int CP_Label_BarcodeType_ITF14 = 28;
|
||
public static final int CP_Label_BarcodeType_EAN14 = 29;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_BarcodeTextPrintPosition
|
||
|
||
标签指令打印条码时,指定条码文字打印位置。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_Label_BarcodeTextPrintPosition_None = 0;
|
||
public static final int CP_Label_BarcodeTextPrintPosition_AboveBarcode = 1;
|
||
public static final int CP_Label_BarcodeTextPrintPosition_BelowBarcode = 2;
|
||
public static final int CP_Label_BarcodeTextPrintPosition_AboveAndBelowBarcode = 3;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_Rotation
|
||
|
||
标签指令绘制控件时,指定旋转角度。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_Label_Rotation_0 = 0;
|
||
public static final int CP_Label_Rotation_90 = 1;
|
||
public static final int CP_Label_Rotation_180 = 2;
|
||
public static final int CP_Label_Rotation_270 = 3;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_Color
|
||
|
||
标签指令绘制控件时,指定绘制颜色。可以是白色或者黑色。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public static final int CP_Label_Color_White = 0;
|
||
public static final int CP_Label_Color_Black = 1;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_PRINTERSTATUS
|
||
|
||
打印机自动回传的状态定义。一般只需要关注是否有错误,信息部分主要是起到提示功能。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public class CP_PrinterStatus {
|
||
private long error_status = 0;
|
||
private long info_status = 0;
|
||
public CP_PrinterStatus(long error_status, long info_status) {
|
||
this.error_status = error_status;
|
||
this.info_status = info_status;
|
||
}
|
||
public long errorStatus() {
|
||
return error_status;
|
||
}
|
||
public long infoStatus() {
|
||
return info_status;
|
||
}
|
||
public boolean ERROR_OCCURED() {
|
||
return error_status != 0;
|
||
}
|
||
public boolean ERROR_CUTTER() {
|
||
return (error_status & 0x01) != 0;
|
||
}
|
||
public boolean ERROR_FLASH() {
|
||
return (error_status & 0x02) != 0;
|
||
}
|
||
public boolean ERROR_NOPAPER() {
|
||
return (error_status & 0x04) != 0;
|
||
}
|
||
public boolean ERROR_VOLTAGE() {
|
||
return (error_status & 0x08) != 0;
|
||
}
|
||
public boolean ERROR_MARKER() {
|
||
return (error_status & 0x10) != 0;
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_RTSTATUS
|
||
|
||
实时状态查询返回的状态定义。此处说明仅供参考,适用于大部分机型,部分机型如不一致,以实际机型指令集为
|
||
|
||
准。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public class CP_RTSTATUS_Helper {
|
||
public static boolean CP_RTSTATUS_DRAWER_OPENED(long status) { return (((status >> 0) & 0x04) == 0x00); };
|
||
public static boolean CP_RTSTATUS_OFFLINE(long status) { return (((status >> 0) & 0x08) == 0x08); };
|
||
public static boolean CP_RTSTATUS_COVERUP(long status) { return (((status >> 8) & 0x04) == 0x04); };
|
||
public static boolean CP_RTSTATUS_FEED_PRESSED(long status) { return (((status >> 8) & 0x08) == 0x08); };
|
||
public static boolean CP_RTSTATUS_NOPAPER(long status) { return (((status >> 8) & 0x20) == 0x20); };
|
||
public static boolean CP_RTSTATUS_ERROR_OCCURED(long status) { return (((status >> 8) & 0x40) == 0x40); };
|
||
public static boolean CP_RTSTATUS_CUTTER_ERROR(long status) { return (((status >> 16) & 0x08) == 0x08); };
|
||
public static boolean CP_RTSTATUS_UNRECOVERABLE_ERROR(long status) { return (((status >> 16) & 0x20) ==
|
||
```
|
||
|
||
0x20); };
|
||
|
||
```java
|
||
public static boolean CP_RTSTATUS_DEGREE_OR_VOLTAGE_OVERRANGE(long status) { return (((status >> 16) &
|
||
```
|
||
|
||
0x40) == 0x40); };
|
||
|
||
```java
|
||
public static boolean CP_RTSTATUS_PAPER_NEAREND(long status) { return (((status >> 24) & 0x08) == 0x08); };
|
||
public static boolean CP_RTSTATUS_PAPER_TAKEOUT(long status) { return (((status >> 24) & 0x04) == 0x04); };
|
||
}
|
||
// 这里的实时状态,共占四字节。
|
||
// 从低字节到高字节依次对应指令集中这四个指令:
|
||
// 10 04 01
|
||
// 10 04 02
|
||
// 10 04 03
|
||
// 10 04 04
|
||
// 部分机型由于定制或其他原因,状态值定义可能与此处不一致,以实测为准。
|
||
//
|
||
// DRAWER_OPENED
|
||
// 钱箱打开
|
||
// OFFLINE
|
||
// 脱机
|
||
// COVERUP
|
||
// 盖子打开
|
||
// FEED_PRESSED
|
||
// 走纸键按下
|
||
// NOPAPER
|
||
// 缺纸
|
||
// ERROR_OCCURED
|
||
// 出错
|
||
// CUTTER_ERROR
|
||
// 切刀错误
|
||
// UNRECOVERABLE_ERROR
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_LABEL_TEXT_STYLE
|
||
|
||
标签指令打印文本时,指定文字打印风格。分别为加粗,下划线,反色,删除线,旋转,宽高加倍。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public class CP_Label_TextStyle {
|
||
private int style = 0;
|
||
public CP_Label_TextStyle(boolean bold, boolean underline, boolean highlight, boolean strikethrough, int
|
||
```
|
||
|
||
rotation, int widthscale, int heightscale) {
|
||
|
||
int style = 0;
|
||
|
||
if (bold)
|
||
|
||
style |= (1 << 0);
|
||
|
||
if (underline)
|
||
|
||
style |= (1 << 1);
|
||
|
||
if (highlight)
|
||
|
||
style |= (1 << 2);
|
||
|
||
if (strikethrough)
|
||
|
||
style |= (1 << 3);
|
||
|
||
style |= (rotation << 4);
|
||
|
||
style |= (widthscale << 8);
|
||
|
||
style |= (heightscale << 12);
|
||
|
||
```java
|
||
this.style = style;
|
||
}
|
||
public int getStyle() {
|
||
return style;
|
||
}
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
### 回调接口
|
||
|
||
CP_OnNetPrinterDiscovered
|
||
|
||
枚举网络打印机时,传入的回调函数。查到到网络打印机时,会回调该函数。
|
||
|
||
定义
|
||
|
||
public interface CP_OnNetPrinterDiscovered_Callback extends Callback {
|
||
|
||
void CP_OnNetPrinterDiscovered(String local_ip, String discovered_mac, String discovered_ip, String
|
||
|
||
discovered_name, Pointer private_data);
|
||
|
||
}
|
||
|
||
#### CP_OnBluetoothDeviceDiscovered
|
||
|
||
枚举蓝牙设备时,传入的回调函数。搜索到蓝牙设备时,会回调该函数。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public interface CP_OnBluetoothDeviceDiscovered_Callback extends Callback {
|
||
```
|
||
|
||
void CP_OnBluetoothDeviceDiscovered(String device_name, String device_address, Pointer private_data);
|
||
|
||
```java
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_OnWiFiP2PDeviceDiscovered
|
||
|
||
枚举WiFiP2P设备时,传入的回调接口。搜索到WiFiP2P设备时,会回调该函数。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public interface CP_OnWiFiP2PDeviceDiscovered_Callback extends Callback {
|
||
```
|
||
|
||
void CP_OnWiFiP2PDeviceDiscovered(String device_name, String device_address, String device_type, Pointer
|
||
|
||
private_data);
|
||
|
||
```java
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_OnPortOpenedEvent
|
||
|
||
端口打开成功时,回调该函数。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public interface CP_OnPortOpenedEvent_Callback extends Callback {
|
||
```
|
||
|
||
void CP_OnPortOpenedEvent(Pointer handle, String name, Pointer private_data);
|
||
|
||
```java
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_OnPortOpenFailedEvent
|
||
|
||
端口打开失败时,回调该函数。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public interface CP_OnPortOpenFailedEvent_Callback extends Callback {
|
||
```
|
||
|
||
void CP_OnPortOpenFailedEvent(Pointer handle, String name, Pointer private_data);
|
||
|
||
```java
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_OnPortClosedEvent
|
||
|
||
端口关闭时,会回调该接口。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public interface CP_OnPortClosedEvent_Callback extends Callback {
|
||
```
|
||
|
||
void CP_OnPortClosedEvent(Pointer handle, Pointer private_data);
|
||
|
||
```java
|
||
}
|
||
```
|
||
|
||
备注
|
||
|
||
端口异常时,比如USB数据线拔出,会自动关闭端口,并触发回调。
|
||
|
||
---
|
||
|
||
#### CP_OnPortWrittenEvent
|
||
|
||
端口写入数据成功时,会回调该函数。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public interface CP_OnPortWrittenEvent_Callback extends Callback {
|
||
```
|
||
|
||
void CP_OnPortWrittenEvent(Pointer handle, Pointer buffer, int count, Pointer private_data);
|
||
|
||
```java
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_OnPortReceivedEvent
|
||
|
||
端口收到数据时,会回调该函数。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public interface CP_OnPortReceivedEvent_Callback extends Callback {
|
||
```
|
||
|
||
void CP_OnPortReceivedEvent(Pointer handle, Pointer buffer, int count, Pointer private_data);
|
||
|
||
```java
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_OnPrinterStatusEvent
|
||
|
||
收到打印机自动回传的状态时,会回调该函数。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public interface CP_OnPrinterStatusEvent_Callback extends Callback {
|
||
```
|
||
|
||
void CP_OnPrinterStatusEvent(Pointer handle, long printer_error_status, long printer_info_status, Pointer
|
||
|
||
private_data);
|
||
|
||
```java
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_OnPrinterReceivedEvent
|
||
|
||
收到打印机自动回传的已接收字节数信息时,会回调该函数。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public interface CP_OnPrinterReceivedEvent_Callback extends Callback {
|
||
```
|
||
|
||
void CP_OnPrinterReceivedEvent(Pointer handle, int printer_received_byte_count, Pointer private_data);
|
||
|
||
```java
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_OnPrinterPrintedEvent
|
||
|
||
收到打印机自动回传的单据打完信息时,会回调该函数。该函数将弃用,不建议使用。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public interface CP_OnPrinterPrintedEvent_Callback extends Callback {
|
||
```
|
||
|
||
void CP_OnPrinterPrintedEvent(Pointer handle, int printer_printed_page_id, Pointer private_data);
|
||
|
||
```java
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
### 添加移除回调
|
||
|
||
CP_Port_AddOnPortOpenedEvent
|
||
|
||
添加回调接口,端口打开成功
|
||
|
||
定义
|
||
|
||
public boolean CP_Port_AddOnPortOpenedEvent(CP_OnPortOpenedEvent_Callback event, Pointer private_data);
|
||
|
||
// 添加回调接口,端口打开成功
|
||
|
||
//
|
||
|
||
// event
|
||
|
||
// 回调接口
|
||
|
||
//
|
||
|
||
// private_data
|
||
|
||
// 传给回调接口的参数
|
||
|
||
//
|
||
|
||
// return
|
||
|
||
// true on success.
|
||
|
||
// false on failed.
|
||
|
||
#### CP_Port_AddOnPortOpenFailedEvent
|
||
|
||
添加回调接口,端口打开失败
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_AddOnPortOpenFailedEvent(CP_OnPortOpenFailedEvent_Callback event, Pointer
|
||
```
|
||
|
||
private_data);
|
||
|
||
```java
|
||
// 添加回调接口,端口打开失败
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// private_data
|
||
// 传给回调接口的参数
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_AddOnPortClosedEvent
|
||
|
||
添加回调接口,端口关闭
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_AddOnPortClosedEvent(CP_OnPortClosedEvent_Callback event, Pointer private_data);
|
||
// 添加回调接口,端口关闭
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// private_data
|
||
// 传给回调接口的参数
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_AddOnPortWrittenEvent
|
||
|
||
添加回调接口,端口写入数据
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_AddOnPortWrittenEvent(CP_OnPortWrittenEvent_Callback event, Pointer private_data);
|
||
// 添加回调接口,端口写入数据
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// private_data
|
||
// 传给回调接口的参数
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_AddOnPortReceivedEvent
|
||
|
||
添加回调接口,端口收到数据
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_AddOnPortReceivedEvent(CP_OnPortReceivedEvent_Callback event, Pointer private_data);
|
||
// 添加回调接口,端口收到数据
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// private_data
|
||
// 传给回调接口的参数
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_RemoveOnPortOpenedEvent
|
||
|
||
移除回调接口
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_RemoveOnPortOpenedEvent(CP_OnPortOpenedEvent_Callback event);
|
||
// 移除回调接口
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_RemoveOnPortOpenFailedEvent
|
||
|
||
移除回调接口
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_RemoveOnPortOpenFailedEvent(CP_OnPortOpenFailedEvent_Callback event);
|
||
// 移除回调接口
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_RemoveOnPortClosedEvent
|
||
|
||
移除回调接口
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_RemoveOnPortClosedEvent(CP_OnPortClosedEvent_Callback event);
|
||
// 移除回调接口
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_RemoveOnPortWrittenEvent
|
||
|
||
移除回调接口
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_RemoveOnPortWrittenEvent(CP_OnPortWrittenEvent_Callback event);
|
||
// 移除回调接口
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_RemoveOnPortReceivedEvent
|
||
|
||
移除回调接口
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_RemoveOnPortReceivedEvent(CP_OnPortReceivedEvent_Callback event);
|
||
// 移除回调接口
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Printer_AddOnPrinterStatusEvent
|
||
|
||
添加回调接口,打印机状态更新
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Printer_AddOnPrinterStatusEvent(CP_OnPrinterStatusEvent_Callback event, Pointer private_data);
|
||
// 添加回调接口,打印机状态更新
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// private_data
|
||
// 传给回调接口的参数
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Printer_AddOnPrinterReceivedEvent
|
||
|
||
添加回调接口,打印机已接收字节数更新
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Printer_AddOnPrinterReceivedEvent(CP_OnPrinterReceivedEvent_Callback event, Pointer
|
||
```
|
||
|
||
private_data);
|
||
|
||
```java
|
||
// 添加回调接口,打印机已接收字节数更新
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// private_data
|
||
// 传给回调接口的参数
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Printer_AddOnPrinterPrintedEvent
|
||
|
||
添加回调接口,打印机已打印页面ID更新
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Printer_AddOnPrinterPrintedEvent(CP_OnPrinterPrintedEvent_Callback event, Pointer
|
||
```
|
||
|
||
private_data);
|
||
|
||
```java
|
||
// 添加回调接口,打印机已打印页面ID更新
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// private_data
|
||
// 传给回调接口的参数
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Printer_RemoveOnPrinterStatusEvent
|
||
|
||
移除回调接口
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Printer_RemoveOnPrinterStatusEvent(CP_OnPrinterStatusEvent_Callback event);
|
||
// 移除回调接口
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Printer_RemoveOnPrinterReceivedEvent
|
||
|
||
移除回调接口
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Printer_RemoveOnPrinterReceivedEvent(CP_OnPrinterReceivedEvent_Callback event);
|
||
// 移除回调接口
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Printer_RemoveOnPrinterPrintedEvent
|
||
|
||
移除回调接口
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Printer_RemoveOnPrinterPrintedEvent(CP_OnPrinterPrintedEvent_Callback event);
|
||
// 移除回调接口
|
||
//
|
||
// event
|
||
// 回调接口
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
### 端口函数
|
||
|
||
CP_Port_EnumCom
|
||
|
||
枚举本地串口
|
||
|
||
定义
|
||
|
||
public class CP_Port_EnumCom_Helper {
|
||
|
||
public static String[] EnumCom()
|
||
|
||
}
|
||
|
||
// return
|
||
|
||
// 枚举到的端口
|
||
|
||
#### CP_Port_EnumUsb
|
||
|
||
枚举本地USB打印口
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public class CP_Port_EnumUsb_Helper {
|
||
public static String[] EnumUsb()
|
||
}
|
||
// return
|
||
// 枚举到的端口
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_EnumNetPrinter
|
||
|
||
枚举网络打印机
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public void CP_Port_EnumNetPrinter(int timeout, IntByReference cancel, CP_OnNetPrinterDiscovered_Callback
|
||
```
|
||
|
||
on_discovered, Pointer data);
|
||
|
||
```java
|
||
// 枚举网络打印机
|
||
//
|
||
// timeout
|
||
// 超时毫秒时间
|
||
//
|
||
// cancel
|
||
// 取消标记位,如果设为非零,则枚举提前退出
|
||
//
|
||
// on_discovered
|
||
// 枚举回调接口
|
||
//
|
||
// private_data
|
||
// 传给回调接口的参数
|
||
//
|
||
// return
|
||
// 无
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_EnumBtDevice
|
||
|
||
枚举蓝牙打印机
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public void CP_Port_EnumBtDevice(int timeout, IntByReference cancel, CP_OnBluetoothDeviceDiscovered_Callback
|
||
```
|
||
|
||
on_discovered, Pointer data);
|
||
|
||
```java
|
||
// 枚举蓝牙打印机
|
||
//
|
||
// timeout
|
||
// 超时毫秒时间
|
||
//
|
||
// cancel
|
||
// 取消标记位,如果设为非零,则枚举提前退出
|
||
//
|
||
// on_discovered
|
||
// 枚举回调接口
|
||
//
|
||
// private_data
|
||
// 传给回调接口的参数
|
||
//
|
||
// return
|
||
// 无
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_EnumBleDevice
|
||
|
||
枚举BLE蓝牙打印机
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public void CP_Port_EnumBleDevice(int timeout, IntByReference cancel, CP_OnBluetoothDeviceDiscovered_Callback
|
||
```
|
||
|
||
on_discovered, Pointer data);
|
||
|
||
```java
|
||
// 枚举BLE蓝牙打印机
|
||
//
|
||
// timeout
|
||
// 超时毫秒时间
|
||
//
|
||
// cancel
|
||
// 取消标记位,如果设为非零,则枚举提前退出
|
||
//
|
||
// on_discovered
|
||
// 枚举回调接口
|
||
//
|
||
// private_data
|
||
// 传给回调接口的参数
|
||
//
|
||
// return
|
||
// 无
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_EnumWiFiP2PDevice
|
||
|
||
枚举WiFi P2P打印机
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public void CP_Port_EnumWiFiP2PDevice(int timeout, IntByReference cancel,
|
||
```
|
||
|
||
CP_OnWiFiP2PDeviceDiscovered_Callback on_discovered, Pointer data);
|
||
|
||
```java
|
||
// 枚举WiFi P2P打印机
|
||
//
|
||
// timeout
|
||
// 超时毫秒时间
|
||
//
|
||
// cancel
|
||
// 取消标记位,如果设为非零,则枚举提前退出
|
||
//
|
||
// on_discovered
|
||
// 枚举回调接口
|
||
//
|
||
// private_data
|
||
// 传给回调接口的参数
|
||
//
|
||
// return
|
||
// 无
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_OpenCom
|
||
|
||
打开串口
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public Pointer CP_Port_OpenCom(String name, int baudrate, int databits, int parity, int stopbits, int flowcontrol, int
|
||
```
|
||
|
||
autoreplymode);
|
||
|
||
```java
|
||
// 打开串口
|
||
//
|
||
// name
|
||
// 端口名称
|
||
// 例如:COM1,COM2,COM3,...COM11...
|
||
//
|
||
// baudrate
|
||
// 波特率
|
||
// 一般取 9600,19200,38400,57600,115200.
|
||
// 需要和打印机波特率保持一致,建议使用高波特率以获得较好的打印速度
|
||
//
|
||
// databits
|
||
// 数据位,范围[4,8]
|
||
//
|
||
// parity
|
||
// 校验位,各值定义如下:
|
||
// 值 定义
|
||
// 0 无校验
|
||
// 1 奇校验
|
||
// 2 偶校验
|
||
// 3 标记校验
|
||
// 4 空白校验
|
||
//
|
||
// stopbits
|
||
// 停止位,各值定义如下:
|
||
// 值 定义
|
||
// 0 1位停止位
|
||
// 1 1.5位停止位
|
||
// 2 2位停止位
|
||
//
|
||
// flowcontrol
|
||
// 流控制
|
||
//
|
||
// autoreplymode
|
||
// 0 不开启自动回传模式
|
||
// 1 开启自动回传模式
|
||
// 注意:
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_OpenUsb
|
||
|
||
打开USB
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public Pointer CP_Port_OpenUsb(String name, int autoreplymode);
|
||
// 打开USB
|
||
//
|
||
// name
|
||
// 端口名称
|
||
// 可由EnumUsb获得
|
||
// 也可以不指定,这时候,如果找到 USB 打印机,会直接打开
|
||
//
|
||
// autoreplymode
|
||
// 0 不开启自动回传模式
|
||
// 1 开启自动回传模式
|
||
// 注意:
|
||
// 仅部分机型支持自动回传模式,是否支持请询问卖家
|
||
// 启动自动回传模式之后,打印机会自动回传状态
|
||
// 不启动则无法自动获取打印机状态
|
||
//
|
||
// return
|
||
// 返回打开的端口句柄。非零表示打开成功,零表示打开失败。
|
||
//
|
||
// remarks
|
||
// USB 打印机接到电脑上,如果设备管理器中出现了 USB Printing Support,则可以使用该函数打开。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_OpenTcp
|
||
|
||
打开网口
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public Pointer CP_Port_OpenTcp(String local_ip, String dest_ip, short dest_port, int timeout, int autoreplymode);
|
||
// 打开网口
|
||
//
|
||
// local_ip
|
||
// 绑定到本地IP
|
||
// 用于多网卡或多个本地IP时,选择指定的IP
|
||
// 传入0表示不指定
|
||
//
|
||
// dest_ip
|
||
// 地址或名称
|
||
// 例如:192.168.1.87
|
||
//
|
||
// dest_port
|
||
// 端口号
|
||
// 固定值:9100
|
||
//
|
||
// timeout
|
||
// 连接超时
|
||
//
|
||
// autoreplymode
|
||
// 0 不开启自动回传模式
|
||
// 1 开启自动回传模式
|
||
// 注意:
|
||
// 仅部分机型支持自动回传模式,是否支持请询问卖家
|
||
// 启动自动回传模式之后,打印机会自动回传状态
|
||
// 不启动则无法自动获取打印机状态
|
||
//
|
||
// return
|
||
// 返回打开的端口句柄。非零表示打开成功,零表示打开失败。
|
||
//
|
||
// remarks
|
||
// PC和打印机需要同网段的才可以连接
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_OpenBtSpp
|
||
|
||
通过SPP连接蓝牙打印机
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public Pointer CP_Port_OpenBtSpp(String address, int autoreplymode);
|
||
// 通过SPP连接蓝牙打印机
|
||
//
|
||
// address
|
||
// 打印机地址
|
||
// 例如:"01:02:03:04:05:06"
|
||
//
|
||
// autoreplymode
|
||
// 0 不开启自动回传模式
|
||
// 1 开启自动回传模式
|
||
// 注意:
|
||
// 仅部分机型支持自动回传模式,是否支持请询问卖家
|
||
// 启动自动回传模式之后,打印机会自动回传状态
|
||
// 不启动则无法自动获取打印机状态
|
||
//
|
||
// return
|
||
// 返回打开的端口句柄。非零表示打开成功,零表示打开失败。
|
||
//
|
||
// remarks
|
||
// only for android
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_OpenBtBle
|
||
|
||
通过BLE连接蓝牙打印机
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public Pointer CP_Port_OpenBtBle(String address, int autoreplymode);
|
||
// 通过BLE连接蓝牙打印机
|
||
//
|
||
// address
|
||
// 打印机地址
|
||
// 例如:"01:02:03:04:05:06"
|
||
//
|
||
// autoreplymode
|
||
// 0 不开启自动回传模式
|
||
// 1 开启自动回传模式
|
||
// 注意:
|
||
// 仅部分机型支持自动回传模式,是否支持请询问卖家
|
||
// 启动自动回传模式之后,打印机会自动回传状态
|
||
// 不启动则无法自动获取打印机状态
|
||
//
|
||
// return
|
||
// 返回打开的端口句柄。非零表示打开成功,零表示打开失败。
|
||
//
|
||
// remarks
|
||
// only for android,ios,macos
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_WiFiP2P_Connect
|
||
|
||
通过WiFi P2P连接打印机
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public int CP_Port_WiFiP2P_Connect(String device_address, int timeout);
|
||
// 通过WiFi P2P连接打印机
|
||
//
|
||
// address
|
||
// 打印机地址
|
||
// 例如:"01:02:03:04:05:06"
|
||
//
|
||
// timeout
|
||
// 连接超时毫秒时间,建议填10000
|
||
//
|
||
// return
|
||
// 返回打印机的IP地址(网络字节序)。
|
||
// 非零表示连接成功,零表示连接失败。
|
||
//
|
||
// remarks
|
||
// only for android
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_WiFiP2P_Disconnect
|
||
|
||
断开WiFi P2P连接
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public void CP_Port_WiFiP2P_Disconnect();
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_WiFiP2P_IsConnected
|
||
|
||
WiFi P2P是否已连接
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_WiFiP2P_IsConnected();
|
||
// WiFi P2P是否已连接
|
||
//
|
||
// return
|
||
// 如果已连接,则返回true
|
||
// 如果未连接,则返回false
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_Write
|
||
|
||
向端口写入数据
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public int CP_Port_Write(Pointer handle, byte[] buffer, int count, int timeout);
|
||
// 向端口写入数据
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// buffer
|
||
// 要写入的数据
|
||
//
|
||
// count
|
||
// 要写入的长度
|
||
//
|
||
// timeout
|
||
// 写入超时毫秒
|
||
//
|
||
// return
|
||
// 返回写入的字节数,-1表示写入失败
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_Read
|
||
|
||
从端口接收数据
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public int CP_Port_Read(Pointer handle, byte[] buffer, int count, int timeout);
|
||
// 从端口接收数据
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// buffer
|
||
// 接收数据的缓冲区
|
||
//
|
||
// count
|
||
// 要接收的数据长度
|
||
//
|
||
// timeout
|
||
// 读取超时毫秒
|
||
//
|
||
// return
|
||
// 返回读取的字节数,-1表示失败
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_ReadUntilByte
|
||
|
||
从端口接收数据
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public int CP_Port_ReadUntilByte(Pointer handle, byte[] buffer, int count, int timeout, byte breakByte);
|
||
// 从端口接收数据
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// buffer
|
||
// 接收数据的缓冲区
|
||
//
|
||
// count
|
||
// 要接收的数据长度
|
||
//
|
||
// timeout
|
||
// 读取超时毫秒
|
||
//
|
||
// breakByte
|
||
// 结束读取字符
|
||
//
|
||
// return
|
||
// 返回读取的字节数,-1表示失败
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_Available
|
||
|
||
返回可读取的字节数
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public int CP_Port_Available(Pointer handle);
|
||
// 返回可读取的字节数
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回可读取的字节数,-1表示失败
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_SkipAvailable
|
||
|
||
忽略接收缓冲区的数据
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_SkipAvailable(Pointer handle);
|
||
// 忽略接收缓冲区的数据
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_IsConnectionValid
|
||
|
||
连接是否有效
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_IsConnectionValid(Pointer handle);
|
||
// 连接是否有效
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 如果端口已打开,且状态持续更新,则返回true
|
||
// 如果端口未打开,已关闭,或状态超过6秒未更新,则返回false
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_IsOpened
|
||
|
||
检查端口是否打开
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_IsOpened(Pointer handle);
|
||
// 检查端口是否打开
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 如果端口已打开,且连接未断开未关闭,则返回true
|
||
// 如果端口未打开,或连接已断开已关闭,则返回false
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Port_Close
|
||
|
||
关闭端口
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Port_Close(Pointer handle);
|
||
// 关闭端口
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
### 获取打印机信息函数
|
||
|
||
CP_Printer_GetPrinterResolutionInfo
|
||
|
||
获取打印机分辨率信息
|
||
|
||
定义
|
||
|
||
public boolean CP_Printer_GetPrinterResolutionInfo(Pointer handle, IntByReference width_mm, IntByReference
|
||
|
||
height_mm, IntByReference dots_per_mm);
|
||
|
||
// 获取打印机分辨率信息
|
||
|
||
//
|
||
|
||
// handle
|
||
|
||
// 端口句柄,由OpenXXX返回
|
||
|
||
//
|
||
|
||
// width_mm
|
||
|
||
// 标签最大宽度
|
||
|
||
//
|
||
|
||
// height_mm
|
||
|
||
// 标签最大高度
|
||
|
||
//
|
||
|
||
// dots_per_mm
|
||
|
||
// 每毫米打印点数
|
||
|
||
//
|
||
|
||
// return
|
||
|
||
// true on success.
|
||
|
||
// false on failed.
|
||
|
||
#### CP_Printer_GetPrinterFirmwareVersion
|
||
|
||
获取打印机固件版本
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public class CP_Printer_GetPrinterFirmwareVersion_Helper {
|
||
public static String GetPrinterFirmwareVersion(Pointer handle)
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Printer_GetPrinterStatusInfo
|
||
|
||
获取打印机自动回传的状态
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Printer_GetPrinterStatusInfo(Pointer handle, LongByReference printer_error_status,
|
||
```
|
||
|
||
LongByReference printer_info_status, LongByReference timestamp_ms);
|
||
|
||
```java
|
||
// 获取打印机自动回传的状态
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// printer_error_status
|
||
// 打印机错误状态
|
||
//
|
||
// printer_info_status
|
||
// 打印机信息状态
|
||
//
|
||
// timestamp_ms
|
||
// 时间戳
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Printer_GetPrinterReceivedInfo
|
||
|
||
获取打印机已接收字节数
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Printer_GetPrinterReceivedInfo(Pointer handle, IntByReference printer_received_byte_count,
|
||
```
|
||
|
||
LongByReference timestamp_ms);
|
||
|
||
```java
|
||
// 获取打印机已接收字节数
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// printer_received_byte_count
|
||
// 打印机已接收字节数
|
||
//
|
||
// timestamp_ms
|
||
// 时间戳
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Printer_GetPrinterPrintedInfo
|
||
|
||
获取打印机已打印的单据号
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Printer_GetPrinterPrintedInfo(Pointer handle, IntByReference printer_printed_page_id,
|
||
```
|
||
|
||
LongByReference timestamp_ms);
|
||
|
||
```java
|
||
// 获取打印机已打印的单据号
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// printer_printed_page_id
|
||
// 打印机已打印的单据号
|
||
//
|
||
// timestamp_ms
|
||
// 时间戳
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Printer_GetPrinterLabelPositionAdjustmentInfo
|
||
|
||
获取打印机标签位置微调信息
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Printer_GetPrinterLabelPositionAdjustmentInfo(Pointer handle, DoubleByReference
|
||
```
|
||
|
||
label_print_position_adjustment, DoubleByReference label_tear_position_adjustment, LongByReference
|
||
|
||
timestamp_ms);
|
||
|
||
```java
|
||
// 获取打印机标签位置微调信息
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// label_print_position_adjustment
|
||
// 打印机标签打印位置微调
|
||
//
|
||
// label_tear_position_adjustment
|
||
// 打印机标签撕纸位置微调
|
||
//
|
||
// timestamp_ms
|
||
// 时间戳
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Printer_SetPrinterLabelPositionAdjustmentInfo
|
||
|
||
设置标签打印位置和撕纸位置微调
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Printer_SetPrinterLabelPositionAdjustmentInfo(Pointer handle, double
|
||
```
|
||
|
||
label_print_position_adjustment, double label_tear_position_adjustment);
|
||
|
||
```java
|
||
// 设置标签打印位置和撕纸位置微调
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// label_print_position_adjustment
|
||
// 标签打印位置微调mm(微调不超过±4mm)
|
||
//
|
||
// label_tear_position_adjustment
|
||
// 标签撕纸位置微调mm(微调不超过±4mm)
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Printer_ClearPrinterBuffer
|
||
|
||
实时清除打印机缓存
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Printer_ClearPrinterBuffer(Pointer handle);
|
||
// 实时清除打印机缓存
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Printer_ClearPrinterError
|
||
|
||
实时清除打印机错误
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Printer_ClearPrinterError(Pointer handle);
|
||
// 实时清除打印机错误
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// true on success.
|
||
// false on failed.
|
||
```
|
||
|
||
---
|
||
|
||
### 票据函数
|
||
|
||
CP_Pos_QueryRTStatus
|
||
|
||
查询打印机实时状态
|
||
|
||
定义
|
||
|
||
public int CP_Pos_QueryRTStatus(Pointer handle, int timeout);
|
||
|
||
// 查询打印机实时状态
|
||
|
||
// 如果是支持自动回传的机型,状态会自动回传,不需要使用本指令查询
|
||
|
||
// 由于实时状态指令,无校验,无法保证结果一定正确
|
||
|
||
//
|
||
|
||
// handle
|
||
|
||
// 端口句柄,由OpenXXX返回
|
||
|
||
//
|
||
|
||
// timeout
|
||
|
||
// 超时毫秒时间。
|
||
|
||
// 查询等待时间不超过此时间。
|
||
|
||
//
|
||
|
||
// return
|
||
|
||
// 返回值仅指示指令是否成功。成功返回实时状态,失败返回0。
|
||
|
||
// 详细状态请查看CP_RTSTATUS_XXX,如果状态定义与实际机型不符,以实测为准。
|
||
|
||
#### CP_Pos_QueryPrintResult
|
||
|
||
查询前面内容的打印结果
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_QueryPrintResult(Pointer handle, int timeout);
|
||
// 查询前面内容的打印结果
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// timeout
|
||
// 超时毫秒时间。
|
||
// 查询打印结果等待时间不超过此时间。
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否打印成功。返回true表示打印成功,返回false表示打印失败或查询失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_KickOutDrawer
|
||
|
||
开钱箱(产生钱箱脉冲)
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_KickOutDrawer(Pointer handle, int nDrawerIndex, int nHighLevelTime, int nLowLevelTime);
|
||
// 开钱箱(产生钱箱脉冲)
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nDrawerIndex
|
||
// 钱箱编号,各值说明如下
|
||
// 编号 说明
|
||
// 0 钱箱引脚2
|
||
// 1 钱箱引脚5
|
||
//
|
||
// nHighLevelTime
|
||
// 高电平毫秒时间
|
||
//
|
||
// nLowLevelTime
|
||
// 低电平毫秒时间
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_Beep
|
||
|
||
蜂鸣器鸣叫
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_Beep(Pointer handle, int nBeepCount, int nBeepMs);
|
||
// 蜂鸣器鸣叫
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nBeepCount
|
||
// 鸣叫次数
|
||
//
|
||
// nBeepMs
|
||
// 蜂鸣毫秒时间,取值范围[100,900]。取整到百毫秒。
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_FeedAndHalfCutPaper
|
||
|
||
走纸到切刀位置并半切纸
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_FeedAndHalfCutPaper(Pointer handle);
|
||
// 走纸到切刀位置并半切纸
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_FullCutPaper
|
||
|
||
切刀全切
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_FullCutPaper(Pointer handle);
|
||
// 切刀全切
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_HalfCutPaper
|
||
|
||
切刀半切
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_HalfCutPaper(Pointer handle);
|
||
// 切刀半切
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_FeedLine
|
||
|
||
打印机进纸指定行数
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_FeedLine(Pointer handle, int numLines);
|
||
// 打印机进纸指定行数
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// numLines
|
||
// 要进的行数
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_FeedDot
|
||
|
||
打印机进纸指定点数
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_FeedDot(Pointer handle, int numDots);
|
||
// 打印机进纸指定点数
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// numDots
|
||
// 要进的点数
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintSelfTestPage
|
||
|
||
打印机打印自检页
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintSelfTestPage(Pointer handle);
|
||
// 打印机打印自检页
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintText
|
||
|
||
打印文本
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintText(Pointer handle, String str);
|
||
// 打印文本
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintTextInUTF8
|
||
|
||
打印文本
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintTextInUTF8(Pointer handle, WString str);
|
||
// 打印文本
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
//
|
||
// remarks
|
||
// 该函数会将数据转为UTF8编码发送。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintTextInGBK
|
||
|
||
打印文本
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintTextInGBK(Pointer handle, WString str);
|
||
// 打印文本
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
//
|
||
// remarks
|
||
// 该函数会将数据转为GBK编码发送。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintTextInBIG5
|
||
|
||
打印文本
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintTextInBIG5(Pointer handle, WString str);
|
||
// 打印文本
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
//
|
||
// remarks
|
||
// 该函数会将数据转为BIG5编码发送。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintTextInShiftJIS
|
||
|
||
打印文本
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintTextInShiftJIS(Pointer handle, WString str);
|
||
// 打印文本
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
//
|
||
// remarks
|
||
// 该函数会将数据转为ShiftJIS编码发送。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintTextInEUCKR
|
||
|
||
打印文本
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintTextInEUCKR(Pointer handle, WString str);
|
||
// 打印文本
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
//
|
||
// remarks
|
||
// 该函数会将数据转为EUCKR编码发送。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintBarcode
|
||
|
||
打印一维条码
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintBarcode(Pointer handle, int nBarcodeType, String str);
|
||
// 打印一维条码
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nBarcodeType
|
||
// 标识条码类型
|
||
// 各值定义如下:
|
||
// 值 类型
|
||
// 0x41 UPC-A
|
||
// 0x42 UPC-E
|
||
// 0x43 EAN13
|
||
// 0x44 EAN8
|
||
// 0x45 CODE39
|
||
// 0x46 ITF
|
||
// 0x47 CODABAR
|
||
// 0x48 CODE93
|
||
// 0x49 CODE128
|
||
//
|
||
// str
|
||
// 要打印的条码
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintBarcode_Code128Auto
|
||
|
||
打印CODE128条码,该函数自动切换编码,以便节省空间
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintBarcode_Code128Auto(Pointer handle, String str);
|
||
// 打印CODE128条码,该函数自动切换编码,以便节省空间
|
||
// 正常情况下,请不要使用这个函数进行打印CODE128码
|
||
// 这个函数主要用于兼容部分老款机型
|
||
// 新款机型默认已经是支持自动切换编码的
|
||
// 新款机型使用这个函数是无法打印条码的
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// str
|
||
// 要打印的条码
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintQRCode
|
||
|
||
打印QR码
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintQRCode(Pointer handle, int nVersion, int nECCLevel, String str);
|
||
// 打印QR码
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nVersion
|
||
// 指定字符版本。取值范围:[0,16]。
|
||
// 当 version 为 0 时,打印机根据字符串长度自动计算版本号。
|
||
//
|
||
// nECCLevel
|
||
// 指定纠错等级。取值范围:[1, 4]。
|
||
// 各值定义如下:
|
||
// ECC 纠错等级
|
||
// 1 L:7%,低纠错,数据多。
|
||
// 2 M:15%,中纠错
|
||
// 3 Q:优化纠错
|
||
// 4 H:30%,最高纠错,数据少。
|
||
//
|
||
// str
|
||
// 要打印的QR码
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintQRCodeUseEpsonCmd
|
||
|
||
打印QR码
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintQRCodeUseEpsonCmd(Pointer handle, int nQRCodeUnitWidth, int nECCLevel, String str);
|
||
// 打印QR码
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nQRCodeUnitWidth
|
||
// QRCode 码码块宽度,取值范围:[1, 16]。
|
||
//
|
||
// nECCLevel
|
||
// 指定纠错等级。取值范围:[1, 4]。
|
||
// 各值定义如下:
|
||
// ECC 纠错等级
|
||
// 1 L:7%,低纠错,数据多。
|
||
// 2 M:15%,中纠错
|
||
// 3 Q:优化纠错
|
||
// 4 H:30%,最高纠错,数据少。
|
||
//
|
||
// str
|
||
// 要打印的QR码
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintQRCodeUseImageCmd
|
||
|
||
打印QR码(以图片指令打印二维码,可用于不支持二维码指令的机型)
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintQRCodeUseImageCmd(Pointer handle, String str, int nVersion, int nQRCodeUnitWidth,
|
||
```
|
||
|
||
int nECCLevel, int compression_method);
|
||
|
||
```java
|
||
// 打印QR码(以图片指令打印二维码,可用于不支持二维码指令的机型)
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// str
|
||
// 要打印的QR码
|
||
//
|
||
// nVersion
|
||
// 指定字符版本。取值范围:[0,16]。
|
||
// 当 version 为 0 时,打印机根据字符串长度自动计算版本号。
|
||
//
|
||
// nQRCodeUnitWidth
|
||
// QRCode 码码块宽度,取值范围:[1, 16]。
|
||
//
|
||
// nECCLevel
|
||
// 指定纠错等级。取值范围:[1, 4]。
|
||
// 各值定义如下:
|
||
// ECC 纠错等级
|
||
// 1 L:7%,低纠错,数据多。
|
||
// 2 M:15%,中纠错
|
||
// 3 Q:优化纠错
|
||
// 4 H:30%,最高纠错,数据少。
|
||
//
|
||
// compression_method
|
||
// 最终打印数据的压缩方式,各值定义如下
|
||
// 值 定义
|
||
// 0 不压缩
|
||
// 1 一级压缩
|
||
// 2 二级压缩
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintDoubleQRCode
|
||
|
||
打印两个QR码
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintDoubleQRCode(Pointer handle, int nQRCodeUnitWidth, int nQR1Position, int
|
||
```
|
||
|
||
nQR1Version, int nQR1ECCLevel, String strQR1, int nQR2Position, int nQR2Version, int nQR2ECCLevel, String strQR2);
|
||
|
||
```java
|
||
// 打印两个QR码
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nQRCodeUnitWidth
|
||
// QRCode 码码块宽度,取值范围:[1, 8]。
|
||
//
|
||
// nQR1Position
|
||
// nQR2Position
|
||
// QRCode position
|
||
//
|
||
// nQR1Version
|
||
// nQR2Version
|
||
// 指定字符版本。取值范围:[0,16]。
|
||
// 当 version 为 0 时,打印机根据字符串长度自动计算版本号。
|
||
//
|
||
// nQR1ECCLevel
|
||
// nQR2ECCLevel
|
||
// 指定纠错等级。取值范围:[1, 4]。
|
||
// 各值定义如下:
|
||
// ECC 纠错等级
|
||
// 1 L:7%,低纠错,数据多。
|
||
// 2 M:15%,中纠错
|
||
// 3 Q:优化纠错
|
||
// 4 H:30%,最高纠错,数据少。
|
||
//
|
||
// strQR1
|
||
// strQR2
|
||
// 要打印的QR码
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintPDF417BarcodeUseEpsonCmd
|
||
|
||
打印PDF417条码
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintPDF417BarcodeUseEpsonCmd(Pointer handle, int columnCount, int rowCount, int
|
||
```
|
||
|
||
unitWidth, int rowHeight, int nECCLevel, int dataProcessingMode, String str);
|
||
|
||
```java
|
||
// 打印PDF417条码
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// columnCount
|
||
// 列数,取值范围[0,30]
|
||
//
|
||
// rowCount
|
||
// 行数,取值范围0,[3,90]
|
||
//
|
||
// unitWidth
|
||
// 模块单元宽度,取值范围[2,8]
|
||
//
|
||
// rowHeight
|
||
// 行高,取值范围[2,8]
|
||
//
|
||
// nECCLevel
|
||
// 指定纠错等级。取值范围:[0,8]。
|
||
//
|
||
// dataProcessingMode
|
||
// 数据处理模式。0选择标准PDF417,1选择截断PDF417。
|
||
//
|
||
// str
|
||
// 要打印的PDF417码
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintRasterImageFromFile
|
||
|
||
打印图片
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintRasterImageFromFile(Pointer handle, int dstw, int dsth, String pszFile, int
|
||
```
|
||
|
||
binaryzation_method, int compression_method);
|
||
|
||
```java
|
||
// 打印图片
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// dstw
|
||
// 要打印的宽度
|
||
//
|
||
// dsth
|
||
// 要打印的高度
|
||
//
|
||
// pszFile
|
||
// 图片的路径
|
||
//
|
||
// binaryzation_method
|
||
// 图片二值化算法。0表示抖动算法,1表示阀值算法,2表示误差扩散法。具体效果请测试查看。
|
||
//
|
||
// compression_method
|
||
// 最终打印数据的压缩方式,各值定义如下
|
||
// 值 定义
|
||
// 0 不压缩
|
||
// 1 一级压缩
|
||
// 2 二级压缩
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintRasterImageFromData
|
||
|
||
打印图片(图片可由文件读取)
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintRasterImageFromData(Pointer handle, int dstw, int dsth, byte[] data, int data_size, int
|
||
```
|
||
|
||
binaryzation_method, int compression_method);
|
||
|
||
```java
|
||
// 打印图片(图片可由文件读取)
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// dstw
|
||
// 要打印的宽度
|
||
//
|
||
// dsth
|
||
// 要打印的高度
|
||
//
|
||
// data
|
||
// 图片数据。
|
||
//
|
||
// data_size
|
||
// 图片数据长度
|
||
//
|
||
// binaryzation_method
|
||
// 图片二值化算法。0表示抖动算法,1表示阀值算法,2表示误差扩散法。具体效果请测试查看。
|
||
//
|
||
// compression_method
|
||
// 最终打印数据的压缩方式,各值定义如下
|
||
// 值 定义
|
||
// 0 不压缩
|
||
// 1 一级压缩
|
||
// 2 二级压缩
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
也可以使用下面的函数
|
||
|
||
```java
|
||
public class CP_Pos_PrintRasterImageFromData_Helper {
|
||
public static boolean PrintRasterImageFromBitmap(Pointer handle, int dstw, int dsth, Bitmap bitmap, int
|
||
```
|
||
|
||
binaryzation_method, int compression_method)
|
||
|
||
```java
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintRasterImageFromPixels
|
||
|
||
打印图片像素数据
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintRasterImageFromPixels(Pointer handle, byte[] img_data, int img_datalen, int img_width,
|
||
```
|
||
|
||
int img_height, int img_stride, int img_format, int binaryzation_method, int compression_method);
|
||
|
||
```java
|
||
// 打印图片像素数据
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// img_data
|
||
// 图片的像素数据。
|
||
//
|
||
// img_datalen
|
||
// 图片的像素数据字节数。
|
||
//
|
||
// img_width
|
||
// 图片的像素宽度。
|
||
//
|
||
// img_height
|
||
// 图片的像素高度。
|
||
//
|
||
// img_stride
|
||
// 图片水平跨度。表示每行字节数。
|
||
//
|
||
// img_format
|
||
// 图片像素数据格式,各值定义如下
|
||
// 值 定义
|
||
// 1 mono
|
||
// 2 monolsb
|
||
// 3 gray
|
||
// 4 r.g.b in byte-ordered
|
||
// 5 b.g.r in byte-ordered
|
||
// 6 a.r.g.b in byte-ordered
|
||
// 7 r.g.b.a in byte-ordered
|
||
// 8 a.b.g.r in byte-ordered
|
||
// 9 b.g.r.a in byte-ordered
|
||
//
|
||
// binaryzation_method
|
||
// 图片二值化算法。0表示抖动算法,1表示阀值算法,2表示误差扩散法。具体效果请测试查看。
|
||
//
|
||
// compression_method
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintHorizontalLine
|
||
|
||
打印一条水平线
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintHorizontalLine(Pointer handle, int nLineStartPosition, int nLineEndPosition);
|
||
// 打印一条水平线
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nLineStartPosition
|
||
// 线段起点位置
|
||
//
|
||
// nLineEndPosition
|
||
// 线段终点位置
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintHorizontalLineSpecifyThickness
|
||
|
||
打印一条水平线
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintHorizontalLineSpecifyThickness(Pointer handle, int nLineStartPosition, int
|
||
```
|
||
|
||
nLineEndPosition, int nLineThickness);
|
||
|
||
```java
|
||
// 打印一条水平线
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nLineStartPosition
|
||
// 线段起点位置
|
||
//
|
||
// nLineEndPosition
|
||
// 线段终点位置
|
||
//
|
||
// nLineThickness
|
||
// 线段粗细
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_PrintMultipleHorizontalLinesAtOneRow
|
||
|
||
同一行上打印多条水平线,连续调用可打印曲线
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_PrintMultipleHorizontalLinesAtOneRow(Pointer handle, int nLineCount, int[]
|
||
```
|
||
|
||
pLineStartPosition, int[] pLineEndPosition);
|
||
|
||
```java
|
||
// 同一行上打印多条水平线,连续调用可打印曲线
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nLineCount
|
||
// 线段条数
|
||
//
|
||
// pLineStartPosition
|
||
// 线段起点位置
|
||
//
|
||
// pLineEndPosition
|
||
// 线段终点位置
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_ResetPrinter
|
||
|
||
复位打印机,清除设置
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_ResetPrinter(Pointer handle);
|
||
// 复位打印机,清除设置
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetPrintSpeed
|
||
|
||
设置打印速度(部分机型支持)
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetPrintSpeed(Pointer handle, int nSpeed);
|
||
// 设置打印速度(部分机型支持)
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nSpeed
|
||
// 打印速度,单位毫米每秒
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetPrintDensity
|
||
|
||
设置打印浓度(部分机型支持)
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetPrintDensity(Pointer handle, int nDensity);
|
||
// 设置打印浓度(部分机型支持)
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nDensity
|
||
// 设置打印浓度[0,15]
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetSingleByteMode
|
||
|
||
设置打印机为单字节编码
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetSingleByteMode(Pointer handle);
|
||
// 设置打印机为单字节编码
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetCharacterSet
|
||
|
||
设置打印机字符集
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetCharacterSet(Pointer handle, int nCharacterSet);
|
||
// 设置打印机字符集
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nCharacterSet
|
||
// 打印机字符集,范围[0,15]
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetCharacterCodepage
|
||
|
||
设置字符代码页
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetCharacterCodepage(Pointer handle, int nCharacterCodepage);
|
||
// 设置字符代码页
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nCharacterCodepage
|
||
// 字符代码页,范围[0,255]
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetMultiByteMode
|
||
|
||
设置打印机为多字节编码
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetMultiByteMode(Pointer handle);
|
||
// 设置打印机为多字节编码
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetMultiByteEncoding
|
||
|
||
设置打印机多字节编码
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetMultiByteEncoding(Pointer handle, int nEncoding);
|
||
// 设置打印机多字节编码
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nEncoding
|
||
// 多字节编码,各值定义如下:
|
||
// 值 定义
|
||
// 0 GBK
|
||
// 1 UTF8
|
||
// 3 BIG5
|
||
// 4 SHIFT-JIS
|
||
// 5 EUC-KR
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetMovementUnit
|
||
|
||
设置打印移动单位
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetMovementUnit(Pointer handle, int nHorizontalMovementUnit, int nVerticalMovementUnit);
|
||
// 设置打印移动单位
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nHorizontalMovementUnit
|
||
// 水平移动单位
|
||
//
|
||
// nVerticalMovementUnit
|
||
// 垂直移动单位
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
//
|
||
// remarks
|
||
// 移动单位设置为200,则1mm=8点。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetPrintAreaLeftMargin
|
||
|
||
设置打印区域左边空白
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetPrintAreaLeftMargin(Pointer handle, int nLeftMargin);
|
||
// 设置打印区域左边空白
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nLeftMargin
|
||
// 左边空白
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetPrintAreaWidth
|
||
|
||
设置打印区域宽度
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetPrintAreaWidth(Pointer handle, int nWidth);
|
||
// 设置打印区域宽度
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nWidth
|
||
// 打印区域宽度
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetHorizontalAbsolutePrintPosition
|
||
|
||
设置横向绝对打印位置
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetHorizontalAbsolutePrintPosition(Pointer handle, int nPosition);
|
||
// 设置横向绝对打印位置
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nPosition
|
||
// 打印位置
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetHorizontalRelativePrintPosition
|
||
|
||
设置横向相对打印位置
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetHorizontalRelativePrintPosition(Pointer handle, int nPosition);
|
||
// 设置横向相对打印位置
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nPosition
|
||
// 打印位置
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetVerticalAbsolutePrintPosition
|
||
|
||
设置纵向绝对打印位置,仅在页模式下有效。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetVerticalAbsolutePrintPosition(Pointer handle, int nPosition);
|
||
// 设置纵向绝对打印位置,仅在页模式下有效。
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nPosition
|
||
// 打印位置
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetVerticalRelativePrintPosition
|
||
|
||
设置纵向相对打印位置,仅在页模式下有效。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetVerticalRelativePrintPosition(Pointer handle, int nPosition);
|
||
// 设置纵向相对打印位置,仅在页模式下有效。
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nPosition
|
||
// 打印位置
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetAlignment
|
||
|
||
设置打印对齐方式
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetAlignment(Pointer handle, int nAlignment);
|
||
// 设置打印对齐方式
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nAlignment
|
||
// 打印对齐方式,各值定义如下:
|
||
// 值 定义
|
||
// 0 左对齐
|
||
// 1 中对齐
|
||
// 2 右对齐
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetTextScale
|
||
|
||
设置文本放大倍数
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetTextScale(Pointer handle, int nWidthScale, int nHeightScale);
|
||
// 设置文本放大倍数
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nWidthScale
|
||
// 宽度放大倍数
|
||
//
|
||
// nHeightScale
|
||
// 高度放大倍数
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetAsciiTextFontType
|
||
|
||
设置英文字符字体类型
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetAsciiTextFontType(Pointer handle, int nFontType);
|
||
// 设置英文字符字体类型
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nFontType
|
||
// 英文字符字体类型,各值定义如下:
|
||
// 值 定义
|
||
// 0 字型A(12x24)
|
||
// 1 字型B(9x17)
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetTextBold
|
||
|
||
设置文本加粗打印
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetTextBold(Pointer handle, int nBold);
|
||
// 设置文本加粗打印
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nBold
|
||
// 是否加粗,各值定义如下:
|
||
// 值 定义
|
||
// 0 不加粗
|
||
// 1 加粗
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetTextUnderline
|
||
|
||
设置文本下划线
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetTextUnderline(Pointer handle, int nUnderline);
|
||
// 设置文本下划线
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nUnderline
|
||
// 文本下划线,各值定义如下:
|
||
// 值 定义
|
||
// 0 无下划线
|
||
// 1 1点下划线
|
||
// 2 2点下划线
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetTextUpsideDown
|
||
|
||
设置文本倒置打印
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetTextUpsideDown(Pointer handle, int nUpsideDown);
|
||
// 设置文本倒置打印
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nUpsideDown
|
||
// 倒置打印,各值定义如下:
|
||
// 值 定义
|
||
// 0 不倒置打印
|
||
// 1 倒置打印
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetTextWhiteOnBlack
|
||
|
||
设置黑白反显
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetTextWhiteOnBlack(Pointer handle, int nWhiteOnBlack);
|
||
// 设置黑白反显
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nWhiteOnBlack
|
||
// 黑白反显,各值定义如下:
|
||
// 值 定义
|
||
// 0 不黑白反显
|
||
// 1 黑白反显
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetTextRotate
|
||
|
||
设置文本旋转90度打印
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetTextRotate(Pointer handle, int nRotate);
|
||
// 设置文本旋转90度打印
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nRotate
|
||
// 旋转打印,各值定义如下:
|
||
// 值 定义
|
||
// 0 不旋转打印
|
||
// 1 旋转90度打印
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetTextLineHeight
|
||
|
||
设置行高
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetTextLineHeight(Pointer handle, int nLineHeight);
|
||
// 设置行高
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nLineHeight
|
||
// 行高,范围[1,255]
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetAsciiTextCharRightSpacing
|
||
|
||
设置ASCII字符右边空白
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetAsciiTextCharRightSpacing(Pointer handle, int nSpacing);
|
||
// 设置ASCII字符右边空白
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nSpacing
|
||
// 右边空白,范围[1,255]
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetKanjiTextCharSpacing
|
||
|
||
设置汉字文本字符左边空白和右边空白
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetKanjiTextCharSpacing(Pointer handle, int nLeftSpacing, int nRightSpacing);
|
||
// 设置汉字文本字符左边空白和右边空白
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nLeftSpacing
|
||
// 右边空白,范围[1,255]
|
||
//
|
||
// nRightSpacing
|
||
// 右边空白,范围[1,255]
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetBarcodeUnitWidth
|
||
|
||
设置条码和二维码单元宽度
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetBarcodeUnitWidth(Pointer handle, int nBarcodeUnitWidth);
|
||
// 设置条码和二维码单元宽度
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nBarcodeUnitWidth
|
||
// 条码单元宽度,取值范围:[1,6]
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetBarcodeHeight
|
||
|
||
设置条码高度
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetBarcodeHeight(Pointer handle, int nBarcodeHeight);
|
||
// 设置条码高度
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nBarcodeHeight
|
||
// 定义条码高度。取值范围:[1,255]
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetBarcodeReadableTextFontType
|
||
|
||
设置条码可读字符字体类型
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetBarcodeReadableTextFontType(Pointer handle, int nFontType);
|
||
// 设置条码可读字符字体类型
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nFontType
|
||
// 指定可读字符的字体类型,各值定义如下:
|
||
// 值 类型
|
||
// 0 标准ASCII
|
||
// 1 压缩ASCII
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Pos_SetBarcodeReadableTextPosition
|
||
|
||
设置条码可读字符打印位置
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Pos_SetBarcodeReadableTextPosition(Pointer handle, int nTextPosition);
|
||
// 设置条码可读字符打印位置
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nTextPosition
|
||
// 条码可读字符位置,取值范围:[0, 3].
|
||
// 各值定义如下:
|
||
// 值 定义
|
||
// 0 不显示可读字符
|
||
// 1 在条码下方显示可读字符
|
||
// 2 在条码上方显示可读字符
|
||
// 3 在条码上方和条码下方显示可读字符
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
### 页模式函数
|
||
|
||
CP_Page_SelectPageMode
|
||
|
||
选择页模式
|
||
|
||
定义
|
||
|
||
public boolean CP_Page_SelectPageMode(Pointer handle);
|
||
|
||
// 选择页模式
|
||
|
||
//
|
||
|
||
// handle
|
||
|
||
// 端口句柄,由OpenXXX返回
|
||
|
||
//
|
||
|
||
// return
|
||
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
|
||
#### CP_Page_SelectPageModeEx
|
||
|
||
选择页模式,并设置移动单位和页面大小,还会设置其他一系列参数为默认值
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_SelectPageModeEx(Pointer handle, int nHorizontalMovementUnit, int
|
||
```
|
||
|
||
nVerticalMovementUnit, int x, int y, int width, int height);
|
||
|
||
```java
|
||
// 选择页模式,并设置移动单位和页面大小,还会设置其他一系列参数为默认值
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nHorizontalMovementUnit
|
||
// 水平移动单位
|
||
//
|
||
// nVerticalMovementUnit
|
||
// 垂直移动单位
|
||
//
|
||
// x
|
||
// 横向起始位置
|
||
//
|
||
// y
|
||
// 纵向起始位置
|
||
//
|
||
// width
|
||
// 打印区域宽度
|
||
//
|
||
// height
|
||
// 打印区域高度
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_ExitPageMode
|
||
|
||
退出页模式并回到标准模式
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_ExitPageMode(Pointer handle);
|
||
// 退出页模式并回到标准模式
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_PrintPage
|
||
|
||
页模式下打印内容
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_PrintPage(Pointer handle);
|
||
// 页模式下打印内容
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_ClearPage
|
||
|
||
页模式下清除页面
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_ClearPage(Pointer handle);
|
||
// 页模式下清除页面
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_SetPageArea
|
||
|
||
页模式下设置页区域,页面最高2000点(1mm8点)
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_SetPageArea(Pointer handle, int x, int y, int width, int height);
|
||
// 页模式下设置页区域,页面最高2000点(1mm8点)
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向起始位置
|
||
//
|
||
// y
|
||
// 纵向起始位置
|
||
//
|
||
// width
|
||
// 打印区域宽度
|
||
//
|
||
// height
|
||
// 打印区域高度
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_SetPageDrawDirection
|
||
|
||
页模式下设置打印方向
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_SetPageDrawDirection(Pointer handle, int nDirection);
|
||
// 页模式下设置打印方向
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nDirection
|
||
// 打印区域方向,各值定义如下:
|
||
// 0 从左到右
|
||
// 1 从下到上
|
||
// 2 从右到左
|
||
// 3 从上到下
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawRect
|
||
|
||
页模式下画矩形
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_DrawRect(Pointer handle, int x, int y, int width, int height, int color);
|
||
// 页模式下画矩形
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// width
|
||
// 矩形宽度
|
||
//
|
||
// height
|
||
// 矩形高度
|
||
//
|
||
// color
|
||
// 矩形颜色,0是白色,1是黑色
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawBox
|
||
|
||
页模式下画矩形框
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_DrawBox(Pointer handle, int x, int y, int width, int height, int borderwidth, int bordercolor);
|
||
// 页模式下画矩形框
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// width
|
||
// 矩形框宽度
|
||
//
|
||
// height
|
||
// 矩形框高度
|
||
//
|
||
// borderwidth
|
||
// 矩形框边框宽度
|
||
//
|
||
// bordercolor
|
||
// 矩形框边框颜色,0是白色,1是黑色
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawText
|
||
|
||
页模式下画文本
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_DrawText(Pointer handle, int x, int y, String str);
|
||
// 页模式下画文本
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawTextInUTF8
|
||
|
||
页模式下画文本
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_DrawTextInUTF8(Pointer handle, int x, int y, WString str);
|
||
// 页模式下画文本
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
//
|
||
// remarks
|
||
// 该函数会将数据转为UTF8编码发送。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawTextInGBK
|
||
|
||
页模式下画文本
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_DrawTextInGBK(Pointer handle, int x, int y, WString str);
|
||
// 页模式下画文本
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
//
|
||
// remarks
|
||
// 该函数会将数据转为GBK编码发送。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawTextInBIG5
|
||
|
||
页模式下画文本
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_DrawTextInBIG5(Pointer handle, int x, int y, WString str);
|
||
// 页模式下画文本
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
//
|
||
// remarks
|
||
// 该函数会将数据转为BIG5编码发送。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawTextInShiftJIS
|
||
|
||
页模式下画文本
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_DrawTextInShiftJIS(Pointer handle, int x, int y, WString str);
|
||
// 页模式下画文本
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
//
|
||
// remarks
|
||
// 该函数会将数据转为ShiftJIS编码发送。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawTextInEUCKR
|
||
|
||
页模式下画文本
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_DrawTextInEUCKR(Pointer handle, int x, int y, WString str);
|
||
// 页模式下画文本
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
//
|
||
// remarks
|
||
// 该函数会将数据转为EUCKR编码发送。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawBarcode
|
||
|
||
页模式下打印一维条码
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_DrawBarcode(Pointer handle, int x, int y, int nBarcodeType, String str);
|
||
// 页模式下打印一维条码
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// nBarcodeType
|
||
// 标识条码类型
|
||
// 各值定义如下:
|
||
// 值 类型
|
||
// 0x41 UPC-A
|
||
// 0x42 UPC-E
|
||
// 0x43 EAN13
|
||
// 0x44 EAN8
|
||
// 0x45 CODE39
|
||
// 0x46 ITF
|
||
// 0x47 CODABAR
|
||
// 0x48 CODE93
|
||
// 0x49 CODE128
|
||
//
|
||
// str
|
||
// 要打印的条码
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawQRCode
|
||
|
||
页模式下打印QR码
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_DrawQRCode(Pointer handle, int x, int y, int nVersion, int nECCLevel, String str);
|
||
// 页模式下打印QR码
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// nVersion
|
||
// 指定字符版本。取值范围:[0,16]。
|
||
// 当 version 为 0 时,打印机根据字符串长度自动计算版本号。
|
||
//
|
||
// nECCLevel
|
||
// 指定纠错等级。取值范围:[1, 4]。
|
||
// 各值定义如下:
|
||
// ECC 纠错等级
|
||
// 1 L:7%,低纠错,数据多。
|
||
// 2 M:15%,中纠错
|
||
// 3 Q:优化纠错
|
||
// 4 H:30%,最高纠错,数据少。
|
||
//
|
||
// str
|
||
// 要打印的QR码
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawRasterImageFromFile
|
||
|
||
页模式下打印图片
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_DrawRasterImageFromFile(Pointer handle, int x, int y, int dstw, int dsth, String pszFile, int
|
||
```
|
||
|
||
binaryzation_method);
|
||
|
||
```java
|
||
// 页模式下打印图片
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// dstw
|
||
// 要打印的宽度
|
||
//
|
||
// dsth
|
||
// 要打印的高度
|
||
//
|
||
// pszFile
|
||
// 图片的路径
|
||
//
|
||
// binaryzation_method
|
||
// 图片二值化算法。0表示抖动算法,1表示阀值算法,2表示误差扩散法。具体效果请测试查看。
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawRasterImageFromData
|
||
|
||
页模式下打印图片(图片可由文件读取)
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_DrawRasterImageFromData(Pointer handle, int x, int y, int dstw, int dsth, byte[] data, int
|
||
```
|
||
|
||
data_size, int binaryzation_method);
|
||
|
||
```java
|
||
// 页模式下打印图片(图片可由文件读取)
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// dstw
|
||
// 要打印的宽度
|
||
//
|
||
// dsth
|
||
// 要打印的高度
|
||
//
|
||
// data
|
||
// 图片数据。
|
||
//
|
||
// data_size
|
||
// 图片数据长度
|
||
//
|
||
// binaryzation_method
|
||
// 图片二值化算法。0表示抖动算法,1表示阀值算法,2表示误差扩散法,2表示误差扩散法。具体效果请
|
||
```
|
||
|
||
测试查看。
|
||
|
||
```java
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
也可以使用下面的函数
|
||
|
||
```java
|
||
public class CP_Page_DrawRasterImageFromData_Helper {
|
||
public static boolean DrawRasterImageFromBitmap(Pointer handle, int x, int y, int dstw, int dsth, Bitmap bitmap,
|
||
```
|
||
|
||
int binaryzation_method)
|
||
|
||
```java
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Page_DrawRasterImageFromPixels
|
||
|
||
页模式下打印图片像素数据
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Page_DrawRasterImageFromPixels(Pointer handle, int x, int y, byte[] img_data, int img_datalen, int
|
||
```
|
||
|
||
img_width, int img_height, int img_stride, int img_format, int binaryzation_method);
|
||
|
||
```java
|
||
// 页模式下打印图片像素数据
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// img_data
|
||
// 图片的像素数据。
|
||
//
|
||
// img_datalen
|
||
// 图片的像素数据字节数。
|
||
//
|
||
// img_width
|
||
// 图片的像素宽度。
|
||
//
|
||
// img_height
|
||
// 图片的像素高度。
|
||
//
|
||
// img_stride
|
||
// 图片水平跨度。表示每行字节数。
|
||
//
|
||
// img_format
|
||
// 图片像素数据格式,各值定义如下
|
||
// 值 定义
|
||
// 1 mono
|
||
// 2 monolsb
|
||
// 3 gray
|
||
// 4 r.g.b in byte-ordered
|
||
// 5 b.g.r in byte-ordered
|
||
// 6 a.r.g.b in byte-ordered
|
||
// 7 r.g.b.a in byte-ordered
|
||
// 8 a.b.g.r in byte-ordered
|
||
```
|
||
|
||
---
|
||
|
||
### 黑标函数
|
||
|
||
CP_BlackMark_EnableBlackMarkMode
|
||
|
||
启用黑标模式,重启打印机生效
|
||
|
||
定义
|
||
|
||
public boolean CP_BlackMark_EnableBlackMarkMode(Pointer handle);
|
||
|
||
// 启用黑标模式,重启打印机生效
|
||
|
||
//
|
||
|
||
// handle
|
||
|
||
// 端口句柄,由OpenXXX返回
|
||
|
||
//
|
||
|
||
// return
|
||
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
|
||
#### CP_BlackMark_DisableBlackMarkMode
|
||
|
||
禁用黑标模式
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_BlackMark_DisableBlackMarkMode(Pointer handle);
|
||
// 禁用黑标模式
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_BlackMark_SetBlackMarkMaxFindLength
|
||
|
||
设置黑标最大查找距离(重启仍有效)
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_BlackMark_SetBlackMarkMaxFindLength(Pointer handle, int maxFindLength);
|
||
// 设置黑标最大查找距离(重启仍有效)
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// maxFindLength
|
||
// 最大查找距离(maxFindLength x 0.125 毫米)
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_BlackMark_FindNextBlackMark
|
||
|
||
查找下一个黑标
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_BlackMark_FindNextBlackMark(Pointer handle);
|
||
// 查找下一个黑标
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_BlackMark_SetBlackMarkPaperPrintPosition
|
||
|
||
黑标模式下,设置起始打印位置的调整值
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_BlackMark_SetBlackMarkPaperPrintPosition(Pointer handle, int position);
|
||
// 黑标模式下,设置起始打印位置的调整值
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// position
|
||
// 大于0则指定为进纸,小于0则指定为退纸。距离为 position x 0.125 毫米。
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_BlackMark_SetBlackMarkPaperCutPosition
|
||
|
||
黑标模式下,设置切纸位置
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_BlackMark_SetBlackMarkPaperCutPosition(Pointer handle, int position);
|
||
// 黑标模式下,设置切纸位置
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// position
|
||
// 大于0则指定为进纸,小于0则指定为退纸。距离为 position x 0.125 毫米。
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_BlackMark_FullCutBlackMarkPaper
|
||
|
||
切刀全切
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_BlackMark_FullCutBlackMarkPaper(Pointer handle);
|
||
// 切刀全切
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_BlackMark_HalfCutBlackMarkPaper
|
||
|
||
切刀半切
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_BlackMark_HalfCutBlackMarkPaper(Pointer handle);
|
||
// 切刀半切
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
### 标签函数
|
||
|
||
CP_Label_EnableLabelMode
|
||
|
||
启用标签模式
|
||
|
||
定义
|
||
|
||
public boolean CP_Label_EnableLabelMode(Pointer handle);
|
||
|
||
// 启用标签模式
|
||
|
||
//
|
||
|
||
// handle
|
||
|
||
// 端口句柄,由OpenXXX返回
|
||
|
||
//
|
||
|
||
// return
|
||
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
|
||
#### CP_Label_DisableLabelMode
|
||
|
||
关闭标签模式
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_DisableLabelMode(Pointer handle);
|
||
// 关闭标签模式
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_CalibrateLabel
|
||
|
||
校准标签纸(更换不同规格标签纸,需要校准)
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_CalibrateLabel(Pointer handle);
|
||
// 校准标签纸(更换不同规格标签纸,需要校准)
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_FeedLabel
|
||
|
||
走纸到标签缝隙处
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_FeedLabel(Pointer handle);
|
||
// 走纸到标签缝隙处
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_BackPaperToPrintPosition
|
||
|
||
打印机退纸到打印位置(适用于标签打印开头定位)
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_BackPaperToPrintPosition(Pointer handle);
|
||
// 打印机退纸到打印位置(适用于标签打印开头定位)
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_FeedPaperToTearPosition
|
||
|
||
打印机进纸到撕纸位置(适用于标签打印结束定位)
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_FeedPaperToTearPosition(Pointer handle);
|
||
// 打印机进纸到撕纸位置(适用于标签打印结束定位)
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_PageBegin
|
||
|
||
指示一个标签页面的开始,并设置标签页的大小,参考点坐标和页面旋转角度
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_PageBegin(Pointer handle, int x, int y, int width, int height, int rotation);
|
||
// 指示一个标签页面的开始,并设置标签页的大小,参考点坐标和页面旋转角度
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 页面起始点 x 坐标
|
||
//
|
||
// y
|
||
// 页面起始点 y 坐标
|
||
//
|
||
// width
|
||
// 页面页宽
|
||
//
|
||
// height
|
||
// 页面页高
|
||
//
|
||
// rotation
|
||
// 页面旋转。 rotate 的取值范围为{0,1}。为 0,页面不旋转打印,为 1,页面旋转 90 度打印。
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_PagePrint
|
||
|
||
将标签页上的内容打印到标签纸上
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_PagePrint(Pointer handle, int copies);
|
||
// 将标签页上的内容打印到标签纸上
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// copies
|
||
// 份数 [ 1 - 255 ]
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_DrawText
|
||
|
||
在标签页面上指定位置绘制文本。只能单行打印。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_DrawText(Pointer handle, int x, int y, int font, int style, String str);
|
||
// 在标签页面上指定位置绘制文本。只能单行打印。
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 定义文本起始位置 x 坐标,取值范围:[0, Page_Width-1]
|
||
//
|
||
// y
|
||
// 定义文本起始位置 y 坐标,取值范围:[0, Page_Height-1]
|
||
//
|
||
// font
|
||
// 选择字体,可以使用24。
|
||
// 带矢量字机型支持16,[20,99]。
|
||
//
|
||
// style
|
||
// 字符风格。
|
||
// 数据位 定义
|
||
// 0 加粗标志位: 置 1 字体加粗,清零则字体不加粗。
|
||
// 1 下划线标志位: 置 1 文本带下划线,清零则无下划线。
|
||
// 2 反白标志位: 置 1 文本反白(黑底白字),清零不反白。
|
||
// 3 删除线标志位: 置 1 文本带删除线,清零则无删除线。
|
||
// [5,4] 旋转标志位: 00 旋转 0° ;
|
||
// 01 旋转 90°;
|
||
// 10 旋转 180°;
|
||
// 11 旋转 270°;
|
||
// [11,8] 字体宽度放大倍数;
|
||
// [15,12] 字体高度放大倍数;
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_DrawTextInUTF8
|
||
|
||
在标签页面上指定位置绘制文本。只能单行打印。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_DrawTextInUTF8(Pointer handle, int x, int y, int font, int style, WString str);
|
||
// 在标签页面上指定位置绘制文本。只能单行打印。
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 定义文本起始位置 x 坐标,取值范围:[0, Page_Width-1]
|
||
//
|
||
// y
|
||
// 定义文本起始位置 y 坐标,取值范围:[0, Page_Height-1]
|
||
//
|
||
// font
|
||
// 选择字体,可以使用24。
|
||
// 带矢量字机型支持16,[20,99]。
|
||
//
|
||
// style
|
||
// 字符风格。
|
||
// 数据位 定义
|
||
// 0 加粗标志位: 置 1 字体加粗,清零则字体不加粗。
|
||
// 1 下划线标志位: 置 1 文本带下划线,清零则无下划线。
|
||
// 2 反白标志位: 置 1 文本反白(黑底白字),清零不反白。
|
||
// 3 删除线标志位: 置 1 文本带删除线,清零则无删除线。
|
||
// [5,4] 旋转标志位: 00 旋转 0° ;
|
||
// 01 旋转 90°;
|
||
// 10 旋转 180°;
|
||
// 11 旋转 270°;
|
||
// [11,8] 字体宽度放大倍数;
|
||
// [15,12] 字体高度放大倍数;
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
//
|
||
// remarks
|
||
// 该函数会将数据转为UTF8编码发送。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_DrawTextInGBK
|
||
|
||
在标签页面上指定位置绘制文本。只能单行打印。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_DrawTextInGBK(Pointer handle, int x, int y, int font, int style, WString str);
|
||
// 在标签页面上指定位置绘制文本。只能单行打印。
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 定义文本起始位置 x 坐标,取值范围:[0, Page_Width-1]
|
||
//
|
||
// y
|
||
// 定义文本起始位置 y 坐标,取值范围:[0, Page_Height-1]
|
||
//
|
||
// font
|
||
// 选择字体,可以使用24。
|
||
// 带矢量字机型支持16,[20,99]。
|
||
//
|
||
// style
|
||
// 字符风格。
|
||
// 数据位 定义
|
||
// 0 加粗标志位: 置 1 字体加粗,清零则字体不加粗。
|
||
// 1 下划线标志位: 置 1 文本带下划线,清零则无下划线。
|
||
// 2 反白标志位: 置 1 文本反白(黑底白字),清零不反白。
|
||
// 3 删除线标志位: 置 1 文本带删除线,清零则无删除线。
|
||
// [5,4] 旋转标志位: 00 旋转 0° ;
|
||
// 01 旋转 90°;
|
||
// 10 旋转 180°;
|
||
// 11 旋转 270°;
|
||
// [11,8] 字体宽度放大倍数;
|
||
// [15,12] 字体高度放大倍数;
|
||
//
|
||
// str
|
||
// 要打印的字符串
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
//
|
||
// remarks
|
||
// 该函数会将数据转为GBK编码发送。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_DrawBarcode
|
||
|
||
在标签页指定位置绘制一维条码。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_DrawBarcode(Pointer handle, int x, int y, int nBarcodeType, int nBarcodeTextPrintPosition,
|
||
```
|
||
|
||
int height, int unitwidth, int rotation, String str);
|
||
|
||
```java
|
||
// 在标签页指定位置绘制一维条码。
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 条码左上角 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
//
|
||
// y
|
||
// 条码左上角 y 坐标值,取值范围:[0, Page_Height-1]。
|
||
//
|
||
// nBarcodeType
|
||
// 标识条码类型
|
||
// 各值定义看宏定义
|
||
//
|
||
// nBarcodeTextPrintPosition
|
||
// 条码可读字符位置,取值范围:[0, 3].
|
||
// 各值定义如下:
|
||
// 值 定义
|
||
// 0 不显示可读字符
|
||
// 1 在条码下方显示可读字符
|
||
// 2 在条码上方显示可读字符
|
||
// 3 在条码上方和条码下方显示可读字符
|
||
//
|
||
// height
|
||
// 定义条码高度。
|
||
//
|
||
// unitwidth
|
||
// 定义码块单元宽度。取值范围:[1, 4]。
|
||
//
|
||
// rotation
|
||
// 表示旋转角度。取值范围:[0, 3]。各值定义如下:
|
||
// 值 定义
|
||
// 0 不旋转绘制。
|
||
// 1 旋转 90°绘制。
|
||
// 2 旋转 180°绘制。
|
||
// 3 旋转 270°绘制。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_DrawQRCode
|
||
|
||
在标签页指定位置绘制QR码。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_DrawQRCode(Pointer handle, int x, int y, int nVersion, int nECCLevel, int unitwidth, int
|
||
```
|
||
|
||
rotation, String str);
|
||
|
||
```java
|
||
// 在标签页指定位置绘制QR码。
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 左上角 x 坐标值,取值范围:[0,Page_Width-1]。
|
||
//
|
||
// y
|
||
// 左上角 y 坐标值,取值范围:[0, Page_Height-1]。
|
||
//
|
||
// nVersion
|
||
// 指定字符版本。取值范围:[0,16]。
|
||
// 当 version 为 0 时,打印机根据字符串长度自动计算版本号。
|
||
//
|
||
// nECCLevel
|
||
// 指定纠错等级。取值范围:[1, 4]。
|
||
// 各值定义如下:
|
||
// ECC 纠错等级
|
||
// 1 L:7%,低纠错,数据多。
|
||
// 2 M:15%,中纠错
|
||
// 3 Q:优化纠错
|
||
// 4 H:30%,最高纠错,数据少。
|
||
//
|
||
// unitwidth
|
||
// 定义码块单元宽度。取值范围:[1, 4]。
|
||
//
|
||
// rotation
|
||
// 表示旋转角度。取值范围:[0, 3]。各值定义如下:
|
||
// 值 定义
|
||
// 0 不旋转绘制。
|
||
// 1 旋转 90°绘制。
|
||
// 2 旋转 180°绘制。
|
||
// 3 旋转 270°绘制。
|
||
//
|
||
// str
|
||
// 要打印的QR码
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_DrawPDF417Code
|
||
|
||
在标签页指定位置绘制 PDF417 条码
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_DrawPDF417Code(Pointer handle, int x, int y, int column, int nAspectRatio, int nECCLevel,
|
||
```
|
||
|
||
int unitwidth, int rotation, String str);
|
||
|
||
```java
|
||
// 在标签页指定位置绘制 PDF417 条码
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 左上角 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
//
|
||
// y
|
||
// 左上角 y 坐标值,取值范围:[0, Page_Height-1]。
|
||
//
|
||
// column
|
||
// ColNum 为列数,表述每行容纳多少码字。一个码字为 17*UnitWidth 个点。行数由打印机自动产生,行数
|
||
```
|
||
|
||
范围限定为 3~90。ColNum 的取值范围:[1,30]。
|
||
|
||
```java
|
||
//
|
||
// nECCLevel
|
||
// 指定纠错等级。取值范围:[0, 8]。
|
||
// 纠错等级取值 纠错码数 可存资料量(字节)
|
||
// 0 2 1108
|
||
// 1 4 1106
|
||
// 2 8 1101
|
||
// 3 16 1092
|
||
// 4 32 1072
|
||
// 5 64 1024
|
||
// 6 128 957
|
||
// 7 256 804
|
||
// 8 512 496
|
||
//
|
||
// unitwidth
|
||
// 定义码块单元宽度。取值范围:[1, 3]。
|
||
//
|
||
// rotation
|
||
// 表示旋转角度。取值范围:[0, 3]。各值定义如下:
|
||
// 值 定义
|
||
// 0 不旋转绘制。
|
||
// 1 旋转 90°绘制。
|
||
// 2 旋转 180°绘制。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_DrawImageFromFile
|
||
|
||
在标签页指定位置绘制位图
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_DrawImageFromFile(Pointer handle, int x, int y, int dstw, int dsth, String pszFile, int
|
||
```
|
||
|
||
binaryzation_method, int compression_method);
|
||
|
||
```java
|
||
// 在标签页指定位置绘制位图
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 左上角 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
//
|
||
// y
|
||
// 左上角 y 坐标值,取值范围:[0, Page_Height-1]。
|
||
//
|
||
// dstw
|
||
// 要打印的宽度
|
||
//
|
||
// dsth
|
||
// 要打印的高度
|
||
//
|
||
// pszFile
|
||
// 图片的路径
|
||
//
|
||
// binaryzation_method
|
||
// 图片二值化算法。0表示抖动算法,1表示阀值算法,2表示误差扩散法。具体效果请测试查看。
|
||
//
|
||
// compression_method
|
||
// 最终打印数据的压缩方式,各值定义如下
|
||
// 值 定义
|
||
// 0 不压缩
|
||
// 1 一级压缩
|
||
// 2 二级压缩
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_DrawImageFromData
|
||
|
||
在标签页指定位置绘制位图
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_DrawImageFromData(Pointer handle, int x, int y, int dstw, int dsth, byte[] data, int data_size,
|
||
```
|
||
|
||
int binaryzation_method, int compression_method);
|
||
|
||
```java
|
||
// 在标签页指定位置绘制位图
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 左上角 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
//
|
||
// y
|
||
// 左上角 y 坐标值,取值范围:[0, Page_Height-1]。
|
||
//
|
||
// dstw
|
||
// 要打印的宽度
|
||
//
|
||
// dsth
|
||
// 要打印的高度
|
||
//
|
||
// data
|
||
// 图片数据。
|
||
//
|
||
// data_size
|
||
// 图片数据长度
|
||
//
|
||
// binaryzation_method
|
||
// 图片二值化算法。0表示抖动算法,1表示阀值算法,2表示误差扩散法。具体效果请测试查看。
|
||
//
|
||
// compression_method
|
||
// 最终打印数据的压缩方式,各值定义如下
|
||
// 值 定义
|
||
// 0 不压缩
|
||
// 1 一级压缩
|
||
// 2 二级压缩
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
也可以使用下面的函数
|
||
|
||
---
|
||
|
||
#### CP_Label_DrawImageFromPixels
|
||
|
||
在标签页指定位置绘制位图
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_DrawImageFromPixels(Pointer handle, int x, int y, byte[] img_data, int img_datalen, int
|
||
```
|
||
|
||
img_width, int img_height, int img_stride, int img_format, int binaryzation_method, int compression_method);
|
||
|
||
```java
|
||
// 在标签页指定位置绘制位图
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 左上角 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
//
|
||
// y
|
||
// 左上角 y 坐标值,取值范围:[0, Page_Height-1]。
|
||
//
|
||
// img_data
|
||
// 图片的像素数据。
|
||
//
|
||
// img_datalen
|
||
// 图片的像素数据字节数。
|
||
//
|
||
// img_width
|
||
// 图片的像素宽度。
|
||
//
|
||
// img_height
|
||
// 图片的像素高度。
|
||
//
|
||
// img_stride
|
||
// 图片水平跨度。表示每行字节数。
|
||
//
|
||
// img_format
|
||
// 图片像素数据格式,各值定义如下
|
||
// 值 定义
|
||
// 1 mono
|
||
// 2 monolsb
|
||
// 3 gray
|
||
// 4 r.g.b in byte-ordered
|
||
// 5 b.g.r in byte-ordered
|
||
// 6 a.r.g.b in byte-ordered
|
||
// 7 r.g.b.a in byte-ordered
|
||
// 8 a.b.g.r in byte-ordered
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_DrawLine
|
||
|
||
在标签页指定位置绘制线段
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_DrawLine(Pointer handle, int startx, int starty, int endx, int endy, int linewidth, int linecolor);
|
||
// 在标签页指定位置绘制线段
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// startx
|
||
// 直线段起始点 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
//
|
||
// starty
|
||
// 直线段起始点 y 坐标值,取值范围:[0,Page_Height-1]。
|
||
//
|
||
// endx
|
||
// 直线段终止点 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
//
|
||
// endy
|
||
// 直线段终止点 y 坐标值,取值范围:[0,Page_Height-1]。
|
||
//
|
||
// linewidth
|
||
// 直线段线宽,取值范围:[1,Page_Height-1]。
|
||
//
|
||
// linecolor
|
||
// 直线段颜色线条颜色,0是白色,1是黑色
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_DrawRect
|
||
|
||
在标签页指定位置绘制矩形
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_DrawRect(Pointer handle, int x, int y, int width, int height, int color);
|
||
// 在标签页指定位置绘制矩形
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// width
|
||
// 矩形宽度
|
||
//
|
||
// height
|
||
// 矩形高度
|
||
//
|
||
// color
|
||
// 矩形颜色,0是白色,1是黑色
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Label_DrawBox
|
||
|
||
在标签页指定位置绘制矩形框
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Label_DrawBox(Pointer handle, int x, int y, int width, int height, int borderwidth, int bordercolor);
|
||
// 在标签页指定位置绘制矩形框
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// x
|
||
// 横向坐标
|
||
//
|
||
// y
|
||
// 纵向坐标
|
||
//
|
||
// width
|
||
// 矩形框宽度
|
||
//
|
||
// height
|
||
// 矩形框高度
|
||
//
|
||
// borderwidth
|
||
// 矩形框边框宽度
|
||
//
|
||
// bordercolor
|
||
// 矩形框边框颜色,0是白色,1是黑色
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
### 其他函数
|
||
|
||
CP_Library_Version
|
||
|
||
获取开发包版本字符串
|
||
|
||
定义
|
||
|
||
public String CP_Library_Version();
|
||
|
||
// 获取开发包版本字符串
|
||
|
||
//
|
||
|
||
// return
|
||
|
||
// 返回开发包版本
|
||
|
||
#### CP_Proto_QueryBatteryLevel
|
||
|
||
查询电池电量
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public int CP_Proto_QueryBatteryLevel(Pointer handle, int timeout);
|
||
// 查询电池电量
|
||
// 仅部分带电池的机型支持该指令
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// timeout
|
||
// 超时毫秒时间。
|
||
// 查询等待时间不超过此时间。
|
||
//
|
||
// return
|
||
// 返回电池电量,范围在0-100之间。返回-1表示查询失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Proto_QuerySerialNumber
|
||
|
||
查询序列号
|
||
|
||
Syntax
|
||
|
||
```java
|
||
public class CP_Proto_QuerySerialNumber_Helper {
|
||
public static String QuerySerialNumber(Pointer handle, int timeout);
|
||
}
|
||
// 查询序列号
|
||
// 仅部分机型支持该命令
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// timeout
|
||
// 超时毫秒时间。
|
||
// 查询等待时间不超过此时间。
|
||
//
|
||
// return
|
||
// 返回序列号
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Proto_SetSystemNameAndSerialNumber
|
||
|
||
设置系统名称和序列号
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Proto_SetSystemNameAndSerialNumber(Pointer handle, String systemName, String
|
||
```
|
||
|
||
serialNumber);
|
||
|
||
```java
|
||
// 设置系统名称和序列号
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// systemName
|
||
// 系统名称
|
||
//
|
||
// serialNumber
|
||
// 序列号
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Proto_SetBluetoothNameAndPassword
|
||
|
||
设置蓝牙名称和密码
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Proto_SetBluetoothNameAndPassword(Pointer handle, String bluetoothName, String
|
||
```
|
||
|
||
bluetoothPassword);
|
||
|
||
```java
|
||
// 设置蓝牙名称和密码
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// bluetoothName
|
||
// 蓝牙名称
|
||
//
|
||
// bluetoothPassword
|
||
// 蓝牙密码
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Proto_SetPTPBasicParameters
|
||
|
||
设置基础信息,包括语言、波特率、浓度等参数,对应设置工具PTP页。
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Proto_SetPTPBasicParameters(Pointer handle, int baudrate, int codepage, int density, int
|
||
```
|
||
|
||
asciiFontType, int lineFeed, int idleTime, int powerOffTime, int maxFeedLength, int pageLength);
|
||
|
||
```java
|
||
// 设置基础信息,包括语言、波特率、浓度等参数,对应设置工具PTP页。
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// baudrate
|
||
// 要设置的波特率
|
||
//
|
||
// codepage
|
||
// 要设置的语言
|
||
// 具体语言对应的数值如下:
|
||
// { ("简体中文"), 255 },
|
||
// { ("繁體中文"), 254 },
|
||
// { ("UTF - 8"), 253 },
|
||
// { ("SHIFT - JIS"), 252 },
|
||
// { ("EUC - KR"), 251 },
|
||
// { ("CP437[U.S.A., Standard Europe]"), 0 },
|
||
// { ("Katakana"), 1 },
|
||
// { ("CP850[Multilingual]"), 2 },
|
||
// { ("CP860[Portuguese]"), 3 },
|
||
// { ("CP863[Canadian - French]"), 4 },
|
||
// { ("CP865[Nordic]"), 5 },
|
||
// { ("WCP1251[Cyrillic]"), 6 },
|
||
// { ("CP866 Cyrilliec #2"), 7 },
|
||
// { ("MIK[Cyrillic / Bulgarian]"), 8 },
|
||
// { ("CP755[East Europe, Latvian 2]"), 9 },
|
||
// { ("Iran"), 10 },
|
||
// { ("CP862[Hebrew]"), 15 },
|
||
// { ("WCP1252 Latin I"), 16 },
|
||
// { ("WCP1253[Greek]"), 17 },
|
||
// { ("CP852[Latina 2]"), 18 },
|
||
// { ("CP858 Multilingual Latin I + Euro)"), 19 },
|
||
// { ("Iran II"), 20 },
|
||
// { ("Latvian"), 21 },
|
||
// { ("CP864[Arabic]"), 22 },
|
||
// { ("ISO - 8859 - 1[West Europe]"), 23 },
|
||
// { ("CP737[Greek]"), 24 },
|
||
```
|
||
|
||
---
|
||
|
||
#### CP_Settings_Hardware_SetPrintSpeed
|
||
|
||
设置打印速度
|
||
|
||
**定义:**
|
||
|
||
```java
|
||
public boolean CP_Settings_Hardware_SetPrintSpeed(Pointer handle, int nSpeed);
|
||
// 设置打印速度
|
||
//
|
||
// handle
|
||
// 端口句柄,由OpenXXX返回
|
||
//
|
||
// nSpeed
|
||
// 打印速度,单位毫米每秒
|
||
//
|
||
// return
|
||
// 返回值仅指示指令是否写入成功。返回true表示写入成功,返回false表示写入失败。
|
||
```
|
||
|
||
---
|