2194 lines
90 KiB
Java
2194 lines
90 KiB
Java
package com.dpkj.modules.autoReplyPrint.utils;
|
||
|
||
import com.sun.jna.*;
|
||
import com.sun.jna.ptr.DoubleByReference;
|
||
import com.sun.jna.ptr.IntByReference;
|
||
import com.sun.jna.ptr.LongByReference;
|
||
|
||
import javax.imageio.ImageIO;
|
||
import java.awt.image.BufferedImage;
|
||
import java.io.ByteArrayOutputStream;
|
||
|
||
public interface AutoReplyPrint extends Library {
|
||
AutoReplyPrint INSTANCE = (AutoReplyPrint) Native.loadLibrary(GetLibraryPath_Helper.GetLibraryPath(), AutoReplyPrint.class);
|
||
int CP_ComDataBits_4 = 4;
|
||
int CP_ComDataBits_5 = 5;
|
||
int CP_ComDataBits_6 = 6;
|
||
int CP_ComDataBits_7 = 7;
|
||
int CP_ComDataBits_8 = 8;
|
||
int CP_ComParity_NoParity = 0;
|
||
int CP_ComParity_OddParity = 1;
|
||
int CP_ComParity_EvenParity = 2;
|
||
int CP_ComParity_MarkParity = 3;
|
||
int CP_ComParity_SpaceParity = 4;
|
||
int CP_ComStopBits_One = 0;
|
||
int CP_ComStopBits_OnePointFive = 1;
|
||
int CP_ComStopBits_Two = 2;
|
||
int CP_ComFlowControl_None = 0;
|
||
int CP_ComFlowControl_XonXoff = 1;
|
||
int CP_ComFlowControl_RtsCts = 2;
|
||
int CP_ComFlowControl_DtrDsr = 3;
|
||
int CP_CharacterSet_USA = 0;
|
||
int CP_CharacterSet_FRANCE = 1;
|
||
int CP_CharacterSet_GERMANY = 2;
|
||
int CP_CharacterSet_UK = 3;
|
||
int CP_CharacterSet_DENMARK_I = 4;
|
||
int CP_CharacterSet_SWEDEN = 5;
|
||
int CP_CharacterSet_ITALY = 6;
|
||
int CP_CharacterSet_SPAIN_I = 7;
|
||
int CP_CharacterSet_JAPAN = 8;
|
||
int CP_CharacterSet_NORWAY = 9;
|
||
int CP_CharacterSet_DENMARK_II = 10;
|
||
int CP_CharacterSet_SPAIN_II = 11;
|
||
int CP_CharacterSet_LATIN = 12;
|
||
int CP_CharacterSet_KOREA = 13;
|
||
int CP_CharacterSet_SLOVENIA = 14;
|
||
int CP_CharacterSet_CHINA = 15;
|
||
int CP_CharacterCodepage_CP437 = 0;
|
||
int CP_CharacterCodepage_KATAKANA = 1;
|
||
int CP_CharacterCodepage_CP850 = 2;
|
||
int CP_CharacterCodepage_CP860 = 3;
|
||
int CP_CharacterCodepage_CP863 = 4;
|
||
int CP_CharacterCodepage_CP865 = 5;
|
||
int CP_CharacterCodepage_WCP1251 = 6;
|
||
int CP_CharacterCodepage_CP866 = 7;
|
||
int CP_CharacterCodepage_MIK = 8;
|
||
int CP_CharacterCodepage_CP755 = 9;
|
||
int CP_CharacterCodepage_IRAN = 10;
|
||
int CP_CharacterCodepage_CP862 = 15;
|
||
int CP_CharacterCodepage_WCP1252 = 16;
|
||
int CP_CharacterCodepage_WCP1253 = 17;
|
||
int CP_CharacterCodepage_CP852 = 18;
|
||
int CP_CharacterCodepage_CP858 = 19;
|
||
int CP_CharacterCodepage_IRAN_II = 20;
|
||
int CP_CharacterCodepage_LATVIAN = 21;
|
||
int CP_CharacterCodepage_CP864 = 22;
|
||
int CP_CharacterCodepage_ISO_8859_1 = 23;
|
||
int CP_CharacterCodepage_CP737 = 24;
|
||
int CP_CharacterCodepage_WCP1257 = 25;
|
||
int CP_CharacterCodepage_THAI = 26;
|
||
int CP_CharacterCodepage_CP720 = 27;
|
||
int CP_CharacterCodepage_CP855 = 28;
|
||
int CP_CharacterCodepage_CP857 = 29;
|
||
int CP_CharacterCodepage_WCP1250 = 30;
|
||
int CP_CharacterCodepage_CP775 = 31;
|
||
int CP_CharacterCodepage_WCP1254 = 32;
|
||
int CP_CharacterCodepage_WCP1255 = 33;
|
||
int CP_CharacterCodepage_WCP1256 = 34;
|
||
int CP_CharacterCodepage_WCP1258 = 35;
|
||
int CP_CharacterCodepage_ISO_8859_2 = 36;
|
||
int CP_CharacterCodepage_ISO_8859_3 = 37;
|
||
int CP_CharacterCodepage_ISO_8859_4 = 38;
|
||
int CP_CharacterCodepage_ISO_8859_5 = 39;
|
||
int CP_CharacterCodepage_ISO_8859_6 = 40;
|
||
int CP_CharacterCodepage_ISO_8859_7 = 41;
|
||
int CP_CharacterCodepage_ISO_8859_8 = 42;
|
||
int CP_CharacterCodepage_ISO_8859_9 = 43;
|
||
int CP_CharacterCodepage_ISO_8859_15 = 44;
|
||
int CP_CharacterCodepage_THAI_2 = 45;
|
||
int CP_CharacterCodepage_CP856 = 46;
|
||
int CP_CharacterCodepage_CP874 = 47;
|
||
int CP_CharacterCodepage_TCVN3 = 48;
|
||
int CP_MultiByteEncoding_GBK = 0;
|
||
int CP_MultiByteEncoding_UTF8 = 1;
|
||
int CP_MultiByteEncoding_BIG5 = 3;
|
||
int CP_MultiByteEncoding_ShiftJIS = 4;
|
||
int CP_MultiByteEncoding_EUCKR = 5;
|
||
int CP_ImageBinarizationMethod_Dithering = 0;
|
||
int CP_ImageBinarizationMethod_Thresholding = 1;
|
||
int CP_ImageBinarizationMethod_ErrorDiffusion = 2;
|
||
int CP_ImageCompressionMethod_None = 0;
|
||
int CP_ImageCompressionMethod_Level1 = 1;
|
||
int CP_ImageCompressionMethod_Level2 = 2;
|
||
int CP_ImagePixelsFormat_MONO = 1;
|
||
int CP_ImagePixelsFormat_MONOLSB = 2;
|
||
int CP_ImagePixelsFormat_GRAY8 = 3;
|
||
int CP_ImagePixelsFormat_BYTEORDERED_RGB24 = 4;
|
||
int CP_ImagePixelsFormat_BYTEORDERED_BGR24 = 5;
|
||
int CP_ImagePixelsFormat_BYTEORDERED_ARGB32 = 6;
|
||
int CP_ImagePixelsFormat_BYTEORDERED_RGBA32 = 7;
|
||
int CP_ImagePixelsFormat_BYTEORDERED_ABGR32 = 8;
|
||
int CP_ImagePixelsFormat_BYTEORDERED_BGRA32 = 9;
|
||
int CP_QRCodeECC_L = 1;
|
||
int CP_QRCodeECC_M = 2;
|
||
int CP_QRCodeECC_Q = 3;
|
||
int CP_QRCodeECC_H = 4;
|
||
int CP_Pos_Alignment_Left = 0;
|
||
int CP_Pos_Alignment_HCenter = 1;
|
||
int CP_Pos_Alignment_Right = 2;
|
||
int CP_Pos_BarcodeType_UPCA = 65;
|
||
int CP_Pos_BarcodeType_UPCE = 66;
|
||
int CP_Pos_BarcodeType_EAN13 = 67;
|
||
int CP_Pos_BarcodeType_EAN8 = 68;
|
||
int CP_Pos_BarcodeType_CODE39 = 69;
|
||
int CP_Pos_BarcodeType_ITF = 70;
|
||
int CP_Pos_BarcodeType_CODEBAR = 71;
|
||
int CP_Pos_BarcodeType_CODE93 = 72;
|
||
int CP_Pos_BarcodeType_CODE128 = 73;
|
||
int CP_Pos_BarcodeTextPrintPosition_None = 0;
|
||
int CP_Pos_BarcodeTextPrintPosition_AboveBarcode = 1;
|
||
int CP_Pos_BarcodeTextPrintPosition_BelowBarcode = 2;
|
||
int CP_Pos_BarcodeTextPrintPosition_AboveAndBelowBarcode = 3;
|
||
int CP_Page_DrawDirection_LeftToRight = 0;
|
||
int CP_Page_DrawDirection_BottomToTop = 1;
|
||
int CP_Page_DrawDirection_RightToLeft = 2;
|
||
int CP_Page_DrawDirection_TopToBottom = 3;
|
||
int CP_Page_DrawAlignment_Left = -1;
|
||
int CP_Page_DrawAlignment_HCenter = -2;
|
||
int CP_Page_DrawAlignment_Right = -3;
|
||
int CP_Page_DrawAlignment_Top = -1;
|
||
int CP_Page_DrawAlignment_VCenter = -2;
|
||
int CP_Page_DrawAlignment_Bottom = -3;
|
||
int CP_Label_BarcodeType_UPCA = 0;
|
||
int CP_Label_BarcodeType_UPCE = 1;
|
||
int CP_Label_BarcodeType_EAN13 = 2;
|
||
int CP_Label_BarcodeType_EAN8 = 3;
|
||
int CP_Label_BarcodeType_CODE39 = 4;
|
||
int CP_Label_BarcodeType_ITF = 5;
|
||
int CP_Label_BarcodeType_CODEBAR = 6;
|
||
int CP_Label_BarcodeType_CODE93 = 7;
|
||
int CP_Label_BarcodeType_CODE128 = 8;
|
||
int CP_Label_BarcodeType_CODE11 = 9;
|
||
int CP_Label_BarcodeType_MSI = 10;
|
||
int CP_Label_BarcodeType_128M = 11;
|
||
int CP_Label_BarcodeType_EAN128 = 12;
|
||
int CP_Label_BarcodeType_25C = 13;
|
||
int CP_Label_BarcodeType_39C = 14;
|
||
int CP_Label_BarcodeType_39 = 15;
|
||
int CP_Label_BarcodeType_EAN13PLUS2 = 16;
|
||
int CP_Label_BarcodeType_EAN13PLUS5 = 17;
|
||
int CP_Label_BarcodeType_EAN8PLUS2 = 18;
|
||
int CP_Label_BarcodeType_EAN8PLUS5 = 19;
|
||
int CP_Label_BarcodeType_POST = 20;
|
||
int CP_Label_BarcodeType_UPCAPLUS2 = 21;
|
||
int CP_Label_BarcodeType_UPCAPLUS5 = 22;
|
||
int CP_Label_BarcodeType_UPCEPLUS2 = 23;
|
||
int CP_Label_BarcodeType_UPCEPLUS5 = 24;
|
||
int CP_Label_BarcodeType_CPOST = 25;
|
||
int CP_Label_BarcodeType_MSIC = 26;
|
||
int CP_Label_BarcodeType_PLESSEY = 27;
|
||
int CP_Label_BarcodeType_ITF14 = 28;
|
||
int CP_Label_BarcodeType_EAN14 = 29;
|
||
int CP_Label_BarcodeTextPrintPosition_None = 0;
|
||
int CP_Label_BarcodeTextPrintPosition_AboveBarcode = 1;
|
||
int CP_Label_BarcodeTextPrintPosition_BelowBarcode = 2;
|
||
int CP_Label_BarcodeTextPrintPosition_AboveAndBelowBarcode = 3;
|
||
int CP_Label_Rotation_0 = 0;
|
||
int CP_Label_Rotation_90 = 1;
|
||
int CP_Label_Rotation_180 = 2;
|
||
int CP_Label_Rotation_270 = 3;
|
||
int CP_Label_Color_White = 0;
|
||
int CP_Label_Color_Black = 1;
|
||
|
||
/**
|
||
* 获取开发包版本字符串
|
||
*
|
||
* @return 返回开发包版本
|
||
*/
|
||
String CP_Library_Version();
|
||
|
||
/**
|
||
* 枚举本地串口
|
||
*
|
||
* @param pBuf 用来保存端口列表的缓冲区
|
||
* @param cbBuf 缓冲区字节数
|
||
* @param pcbNeeded 需要的缓冲区字节数
|
||
* @return 枚举到的端口数量
|
||
*/
|
||
int CP_Port_EnumCom(byte[] pBuf, int cbBuf, IntByReference pcbNeeded);
|
||
|
||
/**
|
||
* 枚举本地并口
|
||
*
|
||
* @param pBuf 用来保存端口列表的缓冲区
|
||
* @param cbBuf 缓冲区字节数
|
||
* @param pcbNeeded 需要的缓冲区字节数
|
||
* @return 枚举到的端口数量
|
||
*/
|
||
int CP_Port_EnumLpt(byte[] pBuf, int cbBuf, IntByReference pcbNeeded);
|
||
|
||
/**
|
||
* 枚举本地 USB 打印口
|
||
*
|
||
* @param pBuf 用来保存端口列表的缓冲区
|
||
* @param cbBuf 缓冲区字节数
|
||
* @param pcbNeeded 需要的缓冲区字节数
|
||
* @return 枚举到的端口数量
|
||
*/
|
||
int CP_Port_EnumUsb(byte[] pBuf, int cbBuf, IntByReference pcbNeeded);
|
||
|
||
/**
|
||
* 枚举网络打印机
|
||
*
|
||
* @param timeout 超时毫秒时间
|
||
* @param cancel 取消标记位,如果设为非零,则枚举提前退出
|
||
* @param on_discovered 枚举回调接口
|
||
* @param private_data 传给回调接口的参数
|
||
* @return 无
|
||
*/
|
||
void CP_Port_EnumNetPrinter(int timeout, IntByReference cancel, CP_OnNetPrinterDiscovered_Callback on_discovered, Pointer private_data);
|
||
|
||
/**
|
||
* 枚举蓝牙打印机
|
||
*
|
||
* @param timeout 超时毫秒时间
|
||
* @param cancel 取消标记位,如果设为非零,则枚举提前退出
|
||
* @param on_discovered 枚举回调接口
|
||
* @param private_data 传给回调接口的参数
|
||
* @return 无
|
||
*/
|
||
void CP_Port_EnumBtDevice(int timeout, IntByReference cancel, CP_OnBluetoothDeviceDiscovered_Callback on_discovered, Pointer private_data);
|
||
|
||
/**
|
||
* 枚举 BLE 蓝牙打印机
|
||
*
|
||
* @param timeout 超时毫秒时间
|
||
* @param cancel 取消标记位,如果设为非零,则枚举提前退出
|
||
* @param on_discovered 枚举回调接口
|
||
* @param private_data 传给回调接口的参数
|
||
* @return 无
|
||
*/
|
||
void CP_Port_EnumBleDevice(int timeout, IntByReference cancel, CP_OnBluetoothDeviceDiscovered_Callback on_discovered, Pointer private_data);
|
||
|
||
/**
|
||
* 打开串口
|
||
*
|
||
* @param name 端口名称,例如:COM1,COM2,COM3,...COM11...
|
||
* @param baudrate 波特率,一般取 9600,19200,38400,57600,115200。
|
||
* 需要和打印机波特率保持一致,建议使用高波特率以获得较好的打印速度
|
||
* @param databits 数据位,范围[4,8]
|
||
* @param parity 校验位,各值定义如下:
|
||
* 值 定义
|
||
* 0 无校验
|
||
* 1 奇校验
|
||
* 2 偶校验
|
||
* 3 标记校验
|
||
* 4 空白校验
|
||
* @param stopbits 停止位,各值定义如下:
|
||
* 值 定义
|
||
* 0 1 位停止位
|
||
* 1 1.5 位停止位
|
||
* 2 2 位停止位
|
||
* @param flowcontrol 流控制
|
||
* @param autoreplymode 0 不开启自动回传模式,1 开启自动回传模式
|
||
* 注意:仅部分机型支持自动回传模式,是否支持请询问卖家
|
||
* 启动自动回传模式之后,打印机会自动回传状态
|
||
* 不启动则无法自动获取打印机状态
|
||
* @return 返回打开的端口句柄。非零表示打开成功,零表示打开失败。
|
||
* 备注:如果串口被占用,打开串口会失败。
|
||
* 如果波特率和打印机波特率不匹配,则无法打印。
|
||
*/
|
||
Pointer CP_Port_OpenCom(String name, int baudrate, int databits, int parity, int stopbits, int flowcontrol, int autoreplymode);
|
||
|
||
/**
|
||
* 打开并口
|
||
*
|
||
* @param name 端口名称,例如:LPT1,LPT2,LPT3...
|
||
* @return 返回打开的端口句柄。非零表示打开成功,零表示打开失败。
|
||
*
|
||
* 备注:并口只有单向通讯,只可写不可读。
|
||
* 一切查询状态的函数,对并口来说均是无效的。
|
||
*/
|
||
Pointer CP_Port_OpenLpt(String name);
|
||
|
||
/**
|
||
* 打开 USB
|
||
*
|
||
* @param name 端口名称,可由 EnumUsb 获得,也可以不指定,这时候,如果找到 USB 打印机,会直接打开
|
||
* @param autoreplymode 0 不开启自动回传模式,1 开启自动回传模式
|
||
* 注意:仅部分机型支持自动回传模式,是否支持请询问卖家
|
||
* 启动自动回传模式之后,打印机会自动回传状态,不启动则无法自动获取打印机状态
|
||
* @return 返回打开的端口句柄。非零表示打开成功,零表示打开失败。
|
||
* 备注:USB 打印机接到电脑上,如果设备管理器中出现了 USB Printing Support,则可以使用该函数打开。
|
||
*/
|
||
Pointer CP_Port_OpenUsb(String name, int autoreplymode);
|
||
|
||
/**
|
||
* 打开网口
|
||
*
|
||
* @param local_ip 绑定到本地 IP,用于多网卡或多个本地 IP 时,选择指定的 IP,传入 0 表示不指定
|
||
* @param dest_ip 地址或名称,例如:192.168.1.87
|
||
* @param dest_port 端口号,固定值:9100
|
||
* @param timeout 连接超时
|
||
* @param autoreplymode 0 不开启自动回传模式,1 开启自动回传模式
|
||
* 注意:仅部分机型支持自动回传模式,是否支持请询问卖家
|
||
* 启动自动回传模式之后,打印机会自动回传状态,不启动则无法自动获取打印机状态
|
||
* @return 返回打开的端口句柄。非零表示打开成功,零表示打开失败。
|
||
* 备注:PC 和打印机需要同网段的才可以连接
|
||
*/
|
||
Pointer CP_Port_OpenTcp(String local_ip, String dest_ip, short dest_port, int timeout, int autoreplymode);
|
||
|
||
/**
|
||
* 通过 SPP 连接蓝牙打印机
|
||
*
|
||
* @param address 打印机地址,例如:"01:02:03:04:05:06"
|
||
* @param autoreplymode 0 不开启自动回传模式,1 开启自动回传模式
|
||
* 注意:仅部分机型支持自动回传模式,是否支持请询问卖家
|
||
* 启动自动回传模式之后,打印机会自动回传状态
|
||
* 不启动则无法自动获取打印机状态
|
||
* @return 返回打开的端口句柄。非零表示打开成功,零表示打开失败。
|
||
*
|
||
* 备注:仅适用于 Android
|
||
*/
|
||
Pointer CP_Port_OpenBtSpp(String address, int autoreplymode);
|
||
|
||
/**
|
||
* 通过 BLE 连接蓝牙打印机
|
||
*
|
||
* @param address 打印机地址,例如:"01:02:03:04:05:06"
|
||
* @param autoreplymode 0 不开启自动回传模式,1 开启自动回传模式
|
||
* 注意:仅部分机型支持自动回传模式,是否支持请询问卖家
|
||
* 启动自动回传模式之后,打印机会自动回传状态,不启动则无法自动获取打印机状态
|
||
* @return 返回打开的端口句柄。非零表示打开成功,零表示打开失败。
|
||
*
|
||
* 备注:仅适用于 Android、iOS、macOS
|
||
*/
|
||
Pointer CP_Port_OpenBtBle(String address, int autoreplymode);
|
||
|
||
/**
|
||
* 向端口写入数据
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param buffer 要写入的数据
|
||
* @param count 要写入的长度
|
||
* @param timeout 写入超时毫秒
|
||
* @return 返回写入的字节数,-1 表示写入失败
|
||
*/
|
||
int CP_Port_Write(Pointer handle, byte[] buffer, int count, int timeout);
|
||
|
||
/**
|
||
* 从端口接收数据
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param buffer 接收数据的缓冲区
|
||
* @param count 要接收的数据长度
|
||
* @param timeout 读取超时毫秒
|
||
* @return 返回读取的字节数,-1 表示失败
|
||
*/
|
||
int CP_Port_Read(Pointer vahandler1, byte[] buffer, int count, int timeout);
|
||
|
||
/**
|
||
* 从端口接收数据直到指定字节
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param buffer 接收数据的缓冲区
|
||
* @param count 要接收的数据长度
|
||
* @param timeout 读取超时毫秒
|
||
* @param breakByte 结束读取字符
|
||
* @return 返回读取的字节数,-1 表示失败
|
||
*/
|
||
int CP_Port_ReadUntilByte(Pointer handle, byte[] buffer, int count, int timeout, byte breakByte);
|
||
|
||
/**
|
||
* 返回可读取的字节数
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回可读取的字节数,-1 表示失败
|
||
*/
|
||
int CP_Port_Available(Pointer handle);
|
||
|
||
/**
|
||
* 忽略接收缓冲区的数据
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Port_SkipAvailable(Pointer handle);
|
||
|
||
/**
|
||
* 连接是否有效
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 如果端口已打开,且状态持续更新,则返回 true
|
||
* 如果端口未打开,已关闭,或状态超过 6 秒未更新,则返回 false
|
||
*/
|
||
boolean CP_Port_IsConnectionValid(Pointer handle);
|
||
|
||
/**
|
||
* 检查端口是否打开
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 如果端口已打开,且连接未断开未关闭,则返回 true
|
||
* 如果端口未打开,或连接已断开已关闭,则返回 false
|
||
*/
|
||
boolean CP_Port_IsOpened(Pointer handle);
|
||
|
||
/**
|
||
* 关闭端口
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Port_Close(Pointer handle);
|
||
|
||
/**
|
||
* 添加回调接口,端口打开成功
|
||
*
|
||
* @param event 回调接口
|
||
* @param private_data 传给回调接口的参数
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Port_AddOnPortOpenedEvent(CP_OnPortOpenedEvent_Callback event, Pointer private_data);
|
||
|
||
/**
|
||
* 添加回调接口,端口打开失败
|
||
*
|
||
* @param event 回调接口
|
||
* @param private_data 传给回调接口的参数
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Port_AddOnPortOpenFailedEvent(CP_OnPortOpenFailedEvent_Callback event, Pointer private_data);
|
||
|
||
/**
|
||
* 添加回调接口,端口关闭
|
||
*
|
||
* @param event 回调接口
|
||
* @param private_data 传给回调接口的参数
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Port_AddOnPortClosedEvent(CP_OnPortClosedEvent_Callback event, Pointer private_data);
|
||
|
||
/**
|
||
* 添加回调接口,端口写入数据
|
||
*
|
||
* @param event 回调接口
|
||
* @param private_data 传给回调接口的参数
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Port_AddOnPortWrittenEvent(CP_OnPortWrittenEvent_Callback event, Pointer private_data);
|
||
|
||
/**
|
||
* 添加回调接口,端口收到数据
|
||
*
|
||
* @param event 回调接口
|
||
* @param private_data 传给回调接口的参数
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Port_AddOnPortReceivedEvent(CP_OnPortReceivedEvent_Callback event, Pointer private_data);
|
||
|
||
/**
|
||
* 移除回调接口
|
||
*
|
||
* @param event 回调接口
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Port_RemoveOnPortOpenedEvent(CP_OnPortOpenedEvent_Callback event);
|
||
|
||
/**
|
||
* 移除回调接口
|
||
*
|
||
* @param event 回调接口
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Port_RemoveOnPortOpenFailedEvent(CP_OnPortOpenFailedEvent_Callback event);
|
||
|
||
/**
|
||
* 移除回调接口
|
||
*
|
||
* @param event 回调接口
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Port_RemoveOnPortClosedEvent(CP_OnPortClosedEvent_Callback event);
|
||
|
||
/**
|
||
* 移除回调接口
|
||
*
|
||
* @param event 回调接口
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Port_RemoveOnPortWrittenEvent(CP_OnPortWrittenEvent_Callback event);
|
||
/**
|
||
* 移除回调接口
|
||
*
|
||
* @param event 回调接口
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Port_RemoveOnPortReceivedEvent(CP_OnPortReceivedEvent_Callback event);
|
||
|
||
/**
|
||
* 添加回调接口,打印机状态更新
|
||
*
|
||
* @param event 回调接口
|
||
* @param private_data 传给回调接口的参数
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_AddOnPrinterStatusEvent(CP_OnPrinterStatusEvent_Callback event, Pointer private_data);
|
||
|
||
/**
|
||
* 添加回调接口,打印机已接收字节数更新
|
||
*
|
||
* @param event 回调接口
|
||
* @param private_data 传给回调接口的参数
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_AddOnPrinterReceivedEvent(CP_OnPrinterReceivedEvent_Callback event, Pointer private_data);
|
||
|
||
/**
|
||
* 添加回调接口,打印机已打印页面 ID 更新
|
||
*
|
||
* @param event 回调接口
|
||
* @param private_data 传给回调接口的参数
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_AddOnPrinterPrintedEvent(CP_OnPrinterPrintedEvent_Callback event, Pointer private_data);
|
||
|
||
/**
|
||
* 移除回调接口
|
||
*
|
||
* @param event 回调接口
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_RemoveOnPrinterStatusEvent(CP_OnPrinterStatusEvent_Callback event);
|
||
|
||
/**
|
||
* 移除回调接口
|
||
*
|
||
* @param event 回调接口
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_RemoveOnPrinterReceivedEvent(CP_OnPrinterReceivedEvent_Callback event);
|
||
|
||
/**
|
||
* 移除回调接口
|
||
*
|
||
* @param event 回调接口
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_RemoveOnPrinterPrintedEvent(CP_OnPrinterPrintedEvent_Callback event);
|
||
/**
|
||
* 获取打印机分辨率信息
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param width_mm 标签最大宽度
|
||
* @param height_mm 标签最大高度
|
||
* @param dots_per_mm 每毫米打印点数
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_GetPrinterResolutionInfo(Pointer handle, IntByReference width_mm, IntByReference height_mm, IntByReference dots_per_mm);
|
||
|
||
/**
|
||
* 获取打印机固件版本
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param pBuf 缓冲区
|
||
* @param cbBuf 缓冲区字节数
|
||
* @param pcbNeeded 需要的缓冲区字节数
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_GetPrinterFirmwareVersion(Pointer handle, byte[] pBuf, int cbBuf, IntByReference pcbNeeded);
|
||
|
||
/**
|
||
* 获取打印机自动回传的状态
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param printer_error_status 打印机错误状态
|
||
* @param printer_info_status 打印机信息状态
|
||
* @param timestamp_ms 时间戳
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_GetPrinterStatusInfo(Pointer handle, LongByReference printer_error_status, LongByReference printer_info_status, LongByReference timestamp_ms);
|
||
|
||
/**
|
||
* 获取打印机已接收字节数
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param printer_received_byte_count 打印机已接收字节数
|
||
* @param timestamp_ms 时间戳
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_GetPrinterReceivedInfo(Pointer handle, IntByReference printer_received_byte_count, LongByReference timestamp_ms);
|
||
|
||
/**
|
||
* 获取打印机已打印的单据号
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param printer_printed_page_id 打印机已打印的单据号
|
||
* @param timestamp_ms 时间戳
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_GetPrinterPrintedInfo(Pointer handle, IntByReference printer_printed_page_id, LongByReference timestamp_ms);
|
||
|
||
/**
|
||
* 获取打印机标签位置微调信息
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param label_print_position_adjustment 打印机标签打印位置微调
|
||
* @param label_tear_position_adjustment 打印机标签撕纸位置微调
|
||
* @param timestamp_ms 时间戳
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_GetPrinterLabelPositionAdjustmentInfo(Pointer handle, DoubleByReference label_print_position_adjustment, DoubleByReference label_tear_position_adjustment, LongByReference timestamp_ms);
|
||
|
||
/**
|
||
* 设置标签打印位置和撕纸位置微调
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param label_print_position_adjustment 标签打印位置微调 mm(微调不超过±4mm)
|
||
* @param label_tear_position_adjustment 标签撕纸位置微调 mm(微调不超过±4mm)
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Printer_SetPrinterLabelPositionAdjustmentInfo(Pointer handle, double label_print_position_adjustment, double label_tear_position_adjustment);
|
||
|
||
/**
|
||
* 实时清除打印机缓存
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_ClearPrinterBuffer(Pointer handle);
|
||
|
||
/**
|
||
* 实时清除打印机错误
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 成功返回 true,失败返回 false。
|
||
*/
|
||
boolean CP_Printer_ClearPrinterError(Pointer handle);
|
||
|
||
/**
|
||
* 查询打印机实时状态
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param timeout 超时毫秒时间。查询等待时间不超过此时间。
|
||
* @return 返回值仅指示指令是否成功。成功返回实时状态,失败返回 0。
|
||
* 详细状态请查看 CP_RTSTATUS_XXX,如果状态定义与实际机型不符,以实测为准。
|
||
*/
|
||
int CP_Pos_QueryRTStatus(Pointer handle, int timeout);
|
||
|
||
/**
|
||
* 查询前面内容的打印结果
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param timeout 超时毫秒时间。查询打印结果等待时间不超过此时间。
|
||
* @return 返回值仅指示指令是否打印成功。返回 true 表示打印成功,返回 false 表示打印失败或查询失败。
|
||
*/
|
||
boolean CP_Pos_QueryPrintResult(Pointer handle, int timeout);
|
||
|
||
/**
|
||
* 开钱箱(产生钱箱脉冲)
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nDrawerIndex 钱箱编号,各值说明如下:0 钱箱引脚 2,1 钱箱引脚 5
|
||
* @param nHighLevelTime 高电平毫秒时间
|
||
* @param nLowLevelTime 低电平毫秒时间
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_KickOutDrawer(Pointer handle, int nDrawerIndex, int nHighLevelTime, int nLowLevelTime);
|
||
|
||
/**
|
||
* 蜂鸣器鸣叫
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nBeepCount 鸣叫次数
|
||
* @param nBeepMs 蜂鸣毫秒时间,取值范围[100,900]。取整到百毫秒。
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_Beep(Pointer handle, int nBeepCount, int nBeepMs);
|
||
|
||
/**
|
||
* 走纸到切刀位置并半切纸
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_FeedAndHalfCutPaper(Pointer handle);
|
||
|
||
/**
|
||
* 切刀全切
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_FullCutPaper(Pointer handle);
|
||
|
||
/**
|
||
* 切刀半切
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_HalfCutPaper(Pointer handle);
|
||
|
||
/**
|
||
* 打印机进纸指定行数
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param numLines 要进的行数
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_FeedLine(Pointer handle, int numLines);
|
||
|
||
/**
|
||
* 打印机进纸指定点数
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param numDots 要进的点数
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_FeedDot(Pointer handle, int numDots);
|
||
|
||
/**
|
||
* 打印机打印自检页
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_PrintSelfTestPage(Pointer handle);
|
||
|
||
/**
|
||
* 打印文本
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_PrintText(Pointer handle, String str);
|
||
|
||
/**
|
||
* 打印文本
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
* 该函数会将数据转为 UTF8 编码发送。
|
||
*/
|
||
boolean CP_Pos_PrintTextInUTF8(Pointer handle, WString str);
|
||
|
||
/**
|
||
* 打印文本
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
* 该函数会将数据转为 GBK 编码发送。
|
||
*/
|
||
boolean CP_Pos_PrintTextInGBK(Pointer handle, WString str);
|
||
|
||
/**
|
||
* 打印文本
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
* 该函数会将数据转为 BIG5 编码发送。
|
||
*/
|
||
boolean CP_Pos_PrintTextInBIG5(Pointer handle, WString str);
|
||
|
||
/**
|
||
* 打印文本
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
* 该函数会将数据转为 ShiftJIS 编码发送。
|
||
*/
|
||
boolean CP_Pos_PrintTextInShiftJIS(Pointer handle, WString str);
|
||
|
||
/**
|
||
* 打印文本
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
* 该函数会将数据转为 EUCKR 编码发送。
|
||
*/
|
||
boolean CP_Pos_PrintTextInEUCKR(Pointer handle, WString str);
|
||
|
||
/**
|
||
* 打印一维条码
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nBarcodeType 标识条码类型
|
||
* @param str 要打印的条码
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_PrintBarcode(Pointer handle, int nBarcodeType, String str);
|
||
|
||
/**
|
||
* 打印 CODE128 条码,该函数自动切换编码,以便节省空间
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param str 要打印的条码
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_PrintBarcode_Code128Auto(Pointer handle, String str);
|
||
|
||
/**
|
||
* 打印 QR 码
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nVersion 指定字符版本。取值范围:[0,16]。
|
||
* @param nECCLevel 指定纠错等级。取值范围:[1, 4]。
|
||
* @param str 要打印的 QR 码
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_PrintQRCode(Pointer handle, int nVersion, int nECCLevel, String str);
|
||
|
||
/**
|
||
* 打印 QR 码
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nQRCodeUnitWidth QRCode 码码块宽度,取值范围:[1, 16]。
|
||
* @param nECCLevel 指定纠错等级。取值范围:[1, 4]。
|
||
* @param str 要打印的 QR 码
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_PrintQRCodeUseEpsonCmd(Pointer handle, int nQRCodeUnitWidth, int nECCLevel, String str);
|
||
|
||
/**
|
||
* 打印两个 QR 码
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nQRCodeUnitWidth QRCode 码码块宽度,取值范围:[1, 8]。
|
||
* @param nQR1Position QRCode 位置
|
||
* @param nQR1Version 指定字符版本。取值范围:[0,16]。
|
||
* @param nQR1ECCLevel 指定纠错等级。取值范围:[1, 4]。
|
||
* @param strQR1 要打印的 QR 码
|
||
* @param nQR2Position QRCode 位置
|
||
* @param nQR2Version 指定字符版本。取值范围:[0,16]。
|
||
* @param nQR2ECCLevel 指定纠错等级。取值范围:[1, 4]。
|
||
* @param strQR2 要打印的 QR 码
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_PrintDoubleQRCode(Pointer handle, int nQRCodeUnitWidth, int nQR1Position, int nQR1Version, int nQR1ECCLevel, String strQR1, int nQR2Position, int nQR2Version, int nQR2ECCLevel, String strQR2);
|
||
|
||
/**
|
||
* 打印 PDF417 条码
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param columnCount 列数,取值范围[0,30]
|
||
* @param rowCount 行数,取值范围 0,[3,90]
|
||
* @param unitWidth 模块单元宽度,取值范围[2,8]
|
||
* @param rowHeight 行高,取值范围[2,8]
|
||
* @param nECCLevel 指定纠错等级。取值范围:[0,8]。
|
||
* @param dataProcessingMode 数据处理模式。0 选择标准 PDF417,1 选择截断 PDF417。
|
||
* @param str 要打印的 PDF417 码
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_PrintPDF417BarcodeUseEpsonCmd(Pointer handle, int columnCount, int rowCount, int unitWidth, int rowHeight, int nECCLevel, int dataProcessingMode, String str);
|
||
|
||
/**
|
||
* 打印图片
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param dstw 要打印的宽度
|
||
* @param dsth 要打印的高度
|
||
* @param pszFile 图片的路径
|
||
* @param binaryzation_method 图片二值化算法。0 表示抖动算法,1 表示阀值算法,2 表示误差扩散法。具体效果请测试查看。
|
||
* @param compression_method 最终打印数据的压缩方式,各值定义如下:0 不压缩,1 一级压缩,2 二级压缩。
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_PrintRasterImageFromFile(Pointer handle, int dstw, int dsth, String pszFile, int binaryzation_method, int compression_method);
|
||
|
||
/**
|
||
* 打印图片(图片可由文件读取)
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param dstw 要打印的宽度
|
||
* @param dsth 要打印的高度
|
||
* @param data 图片数据。
|
||
* @param data_size 图片数据长度
|
||
* @param binaryzation_method 图片二值化算法。0 表示抖动算法,1 表示阀值算法,2 表示误差扩散法。具体效果请测试查看。
|
||
* @param compression_method 最终打印数据的压缩方式,各值定义如下:0 不压缩,1 一级压缩,2 二级压缩。
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_PrintRasterImageFromData(Pointer handle, int dstw, int dsth, byte[] data, int data_size, int binaryzation_method, int compression_method);
|
||
|
||
/**
|
||
* 打印图片像素数据
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param img_data 图片的像素数据。
|
||
* @param img_datalen 图片的像素数据字节数。
|
||
* @param img_width 图片的像素宽度。
|
||
* @param img_height 图片的像素高度。
|
||
* @param img_stride 图片水平跨度。表示每行字节数。
|
||
* @param 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。
|
||
* @param binaryzation_method 图片二值化算法。0 表示抖动算法,1 表示阀值算法,2 表示误差扩散法。具体效果请测试查看。
|
||
* @param compression_method 最终打印数据的压缩方式,各值定义如下:0 不压缩,1 一级压缩,2 二级压缩。
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
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);
|
||
|
||
/**
|
||
* 打印一条水平线
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nLineStartPosition 线段起点位置
|
||
* @param nLineEndPosition 线段终点位置
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_PrintHorizontalLine(Pointer handle, int nLineStartPosition, int nLineEndPosition);
|
||
|
||
/**
|
||
* 打印一条水平线
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nLineStartPosition 线段起点位置
|
||
* @param nLineEndPosition 线段终点位置
|
||
* @param nLineThickness 线段粗细
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_PrintHorizontalLineSpecifyThickness(Pointer handle, int nLineStartPosition, int nLineEndPosition, int nLineThickness);
|
||
|
||
/**
|
||
* 同一行上打印多条水平线,连续调用可打印曲线
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nLineCount 线段条数
|
||
* @param pLineStartPosition 线段起点位置
|
||
* @param pLineEndPosition 线段终点位置
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_PrintMultipleHorizontalLinesAtOneRow(Pointer handle, int nLineCount, int[] pLineStartPosition, int[] pLineEndPosition);
|
||
|
||
/**
|
||
* 复位打印机,清除设置
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_ResetPrinter(Pointer handle);
|
||
|
||
/**
|
||
* 设置打印速度(部分机型支持)
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nSpeed 打印速度,单位毫米每秒
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetPrintSpeed(Pointer handle, int nSpeed);
|
||
|
||
/**
|
||
* 设置打印浓度(部分机型支持)
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nDensity 设置打印浓度[0,15]
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetPrintDensity(Pointer handle, int nDensity);
|
||
|
||
/**
|
||
* 设置打印机为单字节编码
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetSingleByteMode(Pointer handle);
|
||
|
||
/**
|
||
* 设置打印机字符集
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nCharacterSet 打印机字符集,范围[0,15]
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetCharacterSet(Pointer handle, int nCharacterSet);
|
||
|
||
/**
|
||
* 设置字符代码页
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nCharacterCodepage 字符代码页,范围[0,255]
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetCharacterCodepage(Pointer handle, int nCharacterCodepage);
|
||
|
||
/**
|
||
* 设置打印机为多字节编码
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetMultiByteMode(Pointer handle);
|
||
|
||
/**
|
||
* 设置打印机多字节编码
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nEncoding 多字节编码,各值定义如下:
|
||
* 值 定义
|
||
* 0 GBK
|
||
* 1 UTF8
|
||
* 3 BIG5
|
||
* 4 SHIFT-JIS
|
||
* 5 EUC-KR
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetMultiByteEncoding(Pointer handle, int nEncoding);
|
||
|
||
/**
|
||
* 设置打印移动单位
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nHorizontalMovementUnit 水平移动单位
|
||
* @param nVerticalMovementUnit 垂直移动单位
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
* 移动单位设置为 200,则 1mm=8 点。
|
||
*/
|
||
boolean CP_Pos_SetMovementUnit(Pointer handle, int nHorizontalMovementUnit, int nVerticalMovementUnit);
|
||
|
||
/**
|
||
* 设置打印区域左边空白
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nLeftMargin 左边空白
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetPrintAreaLeftMargin(Pointer handle, int nLeftMargin);
|
||
|
||
/**
|
||
* 设置打印区域宽度
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nWidth 打印区域宽度
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetPrintAreaWidth(Pointer handle, int nWidth);
|
||
|
||
/**
|
||
* 设置横向绝对打印位置
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nPosition 打印位置
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetHorizontalAbsolutePrintPosition(Pointer handle, int nPosition);
|
||
|
||
/**
|
||
* 设置横向相对打印位置
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nPosition 打印位置
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetHorizontalRelativePrintPosition(Pointer handle, int nPosition);
|
||
|
||
/**
|
||
* 设置纵向绝对打印位置,仅在页模式下有效。
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nPosition 打印位置
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetVerticalAbsolutePrintPosition(Pointer handle, int nPosition);
|
||
|
||
/**
|
||
* 设置纵向相对打印位置,仅在页模式下有效。
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nPosition 打印位置
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetVerticalRelativePrintPosition(Pointer handle, int nPosition);
|
||
|
||
/**
|
||
* 设置打印对齐方式
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nAlignment 打印对齐方式,各值定义如下:
|
||
* 值 定义
|
||
* 0 左对齐
|
||
* 1 中对齐
|
||
* 2 右对齐
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetAlignment(Pointer handle, int nAlignment);
|
||
|
||
/**
|
||
* 设置文本放大倍数
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nWidthScale 宽度放大倍数
|
||
* @param nHeightScale 高度放大倍数
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetTextScale(Pointer handle, int nWidthScale, int nHeightScale);
|
||
|
||
/**
|
||
* 设置英文字符字体类型
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nFontType 英文字符字体类型,各值定义如下:
|
||
* 值 定义
|
||
* 0 字型 A(12x24)
|
||
* 1 字型 B(9x17)
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetAsciiTextFontType(Pointer handle, int nFontType);
|
||
|
||
/**
|
||
* 设置文本加粗打印
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nBold 是否加粗,各值定义如下:
|
||
* 值 定义
|
||
* 0 不加粗
|
||
* 1 加粗
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetTextBold(Pointer handle, int nBold);
|
||
|
||
/**
|
||
* 设置文本下划线
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nUnderline 文本下划线,各值定义如下:
|
||
* 值 定义
|
||
* 0 无下划线
|
||
* 1 1 点下划线
|
||
* 2 2 点下划线
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetTextUnderline(Pointer handle, int nUnderline);
|
||
|
||
/**
|
||
* 设置文本倒置打印
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nUpsideDown 倒置打印,各值定义如下:
|
||
* 值 定义
|
||
* 0 不倒置打印
|
||
* 1 倒置打印
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetTextUpsideDown(Pointer handle, int nUpsideDown);
|
||
|
||
/**
|
||
* 设置黑白反显
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nWhiteOnBlack 黑白反显,各值定义如下:
|
||
* 值 定义
|
||
* 0 不黑白反显
|
||
* 1 黑白反显
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetTextWhiteOnBlack(Pointer handle, int nWhiteOnBlack);
|
||
|
||
/**
|
||
* 设置文本旋转 90 度打印
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nRotate 旋转打印,各值定义如下:
|
||
* 值 定义
|
||
* 0 不旋转打印
|
||
* 1 旋转 90 度打印
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetTextRotate(Pointer handle, int nRotate);
|
||
|
||
/**
|
||
* 设置行高
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nLineHeight 行高,范围[1,255]
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetTextLineHeight(Pointer handle, int nLineHeight);
|
||
|
||
/**
|
||
* 设置 ASCII 字符右边空白
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nSpacing 右边空白,范围[1,255]
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetAsciiTextCharRightSpacing(Pointer handle, int nSpacing);
|
||
|
||
/**
|
||
* 设置汉字文本字符左边空白和右边空白
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nLeftSpacing 左边空白,范围[1,255]
|
||
* @param nRightSpacing 右边空白,范围[1,255]
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetKanjiTextCharSpacing(Pointer handle, int nLeftSpacing, int nRightSpacing);
|
||
|
||
/**
|
||
* 设置条码和二维码单元宽度
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nBarcodeUnitWidth 条码单元宽度,取值范围:[1,6]
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetBarcodeUnitWidth(Pointer handle, int nBarcodeUnitWidth);
|
||
|
||
/**
|
||
* 设置条码高度
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nBarcodeHeight 定义条码高度。取值范围:[1,255]
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetBarcodeHeight(Pointer handle, int nBarcodeHeight);
|
||
|
||
/**
|
||
* 设置条码可读字符字体类型
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nFontType 指定可读字符的字体类型,各值定义如下:
|
||
* 值 类型
|
||
* 0 标准 ASCII
|
||
* 1 压缩 ASCII
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetBarcodeReadableTextFontType(Pointer handle, int nFontType);
|
||
|
||
/**
|
||
* 设置条码可读字符打印位置
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nTextPosition 条码可读字符位置,取值范围:[0, 3]。
|
||
* 各值定义如下:
|
||
* 值 定义
|
||
* 0 不显示可读字符
|
||
* 1 在条码下方显示可读字符
|
||
* 2 在条码上方显示可读字符
|
||
* 3 在条码上方和条码下方显示可读字符
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Pos_SetBarcodeReadableTextPosition(Pointer handle, int nTextPosition);
|
||
|
||
/**
|
||
* 选择页模式
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_SelectPageMode(Pointer handle);
|
||
|
||
/**
|
||
* 选择页模式,并设置移动单位和页面大小,还会设置其他一系列参数为默认值
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nHorizontalMovementUnit 水平移动单位
|
||
* @param nVerticalMovementUnit 垂直移动单位
|
||
* @param x 横向起始位置
|
||
* @param y 纵向起始位置
|
||
* @param width 打印区域宽度
|
||
* @param height 打印区域高度
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_SelectPageModeEx(Pointer handle, int nHorizontalMovementUnit, int nVerticalMovementUnit, int x, int y, int width, int height);
|
||
|
||
/**
|
||
* 退出页模式并回到标准模式
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_ExitPageMode(Pointer handle);
|
||
|
||
/**
|
||
* 页模式下打印内容
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_PrintPage(Pointer handle);
|
||
|
||
/**
|
||
* 页模式下清除页面
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_ClearPage(Pointer handle);
|
||
|
||
/**
|
||
* 页模式下设置页区域,页面最高 2000 点(1mm=8点)
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向起始位置
|
||
* @param y 纵向起始位置
|
||
* @param width 打印区域宽度
|
||
* @param height 打印区域高度
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_SetPageArea(Pointer handle, int x, int y, int width, int height);
|
||
|
||
/**
|
||
* 页模式下设置打印方向
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param nDirection 打印区域方向,各值定义如下:
|
||
* 0 从左到右
|
||
* 1 从下到上
|
||
* 2 从右到左
|
||
* 3 从上到下
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_SetPageDrawDirection(Pointer handle, int nDirection);
|
||
|
||
/**
|
||
* 页模式下画矩形
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param width 矩形宽度
|
||
* @param height 矩形高度
|
||
* @param color 矩形颜色,0 是白色,1 是黑色
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_DrawRect(Pointer handle, int x, int y, int width, int height, int color);
|
||
|
||
/**
|
||
* 页模式下画矩形框
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param width 矩形框宽度
|
||
* @param height 矩形框高度
|
||
* @param borderwidth 矩形框边框宽度
|
||
* @param bordercolor 矩形框边框颜色,0 是白色,1 是黑色
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_DrawBox(Pointer handle, int x, int y, int width, int height, int borderwidth, int bordercolor);
|
||
|
||
/**
|
||
* 页模式下画文本
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_DrawText(Pointer handle, int x, int y, String str);
|
||
|
||
/**
|
||
* 页模式下画文本
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
* 该函数会将数据转为 UTF8 编码发送。
|
||
*/
|
||
boolean CP_Page_DrawTextInUTF8(Pointer handle, int x, int y, WString str);
|
||
|
||
/**
|
||
* 页模式下画文本
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
* 该函数会将数据转为 GBK 编码发送。
|
||
*/
|
||
boolean CP_Page_DrawTextInGBK(Pointer handle, int x, int y, WString str);
|
||
|
||
/**
|
||
* 页模式下画文本
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
* 该函数会将数据转为 BIG5 编码发送。
|
||
*/
|
||
boolean CP_Page_DrawTextInBIG5(Pointer handle, int x, int y, WString str);
|
||
|
||
/**
|
||
* 页模式下画文本
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
* 该函数会将数据转为 ShiftJIS 编码发送。
|
||
*/
|
||
boolean CP_Page_DrawTextInShiftJIS(Pointer handle, int x, int y, WString str);
|
||
|
||
/**
|
||
* 页模式下画文本
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
* 该函数会将数据转为 EUCKR 编码发送。
|
||
*/
|
||
boolean CP_Page_DrawTextInEUCKR(Pointer handle, int x, int y, WString str);
|
||
|
||
/**
|
||
* 页模式下打印一维条码
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param nBarcodeType 标识条码类型,各值定义如下:
|
||
* 值 类型
|
||
* 0x41 UPC-A
|
||
* 0x42 UPC-E
|
||
* 0x43 EAN13
|
||
* 0x44 EAN8
|
||
* 0x45 CODE39
|
||
* 0x46 ITF
|
||
* 0x47 CODABAR
|
||
* 0x48 CODE93
|
||
* 0x49 CODE128
|
||
* @param str 要打印的条码
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_DrawBarcode(Pointer handle, int x, int y, int nBarcodeType, String str);
|
||
|
||
/**
|
||
* 页模式下打印 QR 码
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param nVersion 指定字符版本。取值范围:[0,16]。当 version 为 0 时,打印机根据字符串长度自动计算版本号。
|
||
* @param nECCLevel 指定纠错等级。取值范围:[1, 4]。各值定义如下:
|
||
* ECC 纠错等级
|
||
* 1 L:7%,低纠错,数据多。
|
||
* 2 M:15%,中纠错
|
||
* 3 Q:优化纠错
|
||
* 4 H:30%,最高纠错,数据少。
|
||
* @param str 要打印的 QR 码
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_DrawQRCode(Pointer handle, int x, int y, int nVersion, int nECCLevel, String str);
|
||
|
||
/**
|
||
* 页模式下打印图片
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param dstw 要打印的宽度
|
||
* @param dsth 要打印的高度
|
||
* @param pszFile 图片的路径
|
||
* @param binaryzation_method 图片二值化算法。0 表示抖动算法,1 表示阀值算法,2 表示误差扩散法。具体效果请测试查看。
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_DrawRasterImageFromFile(Pointer handle, int x, int y, int dstw, int dsth, String pszFile, int binaryzation_method);
|
||
|
||
/**
|
||
* 页模式下打印图片(图片可由文件读取)
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param dstw 要打印的宽度
|
||
* @param dsth 要打印的高度
|
||
* @param data 图片数据。
|
||
* @param data_size 图片数据长度
|
||
* @param binaryzation_method 图片二值化算法。0 表示抖动算法,1 表示阀值算法,2 表示误差扩散法。具体效果请测试查看。
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Page_DrawRasterImageFromData(Pointer handle, int x, int y, int dstw, int dsth, byte[] data, int data_size, int binaryzation_method);
|
||
|
||
/**
|
||
* 页模式下打印图片像素数据
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param img_data 图片的像素数据。
|
||
* @param img_datalen 图片的像素数据字节数。
|
||
* @param img_width 图片的像素宽度。
|
||
* @param img_height 图片的像素高度。
|
||
* @param img_stride 图片水平跨度。表示每行字节数。
|
||
* @param 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
|
||
* @param binaryzation_method 图片二值化算法。0 表示抖动算法,1 表示阀值算法,2 表示误差扩散法。具体效果请测试查看。
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
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);
|
||
|
||
/**
|
||
* 启用黑标模式,重启打印机生效
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_BlackMark_EnableBlackMarkMode(Pointer handle);
|
||
|
||
/**
|
||
* 禁用黑标模式
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_BlackMark_DisableBlackMarkMode(Pointer handle);
|
||
|
||
/**
|
||
* 设置黑标最大查找距离(重启仍有效)
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param maxFindLength 最大查找距离(maxFindLength x 0.125 毫米)
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_BlackMark_SetBlackMarkMaxFindLength(Pointer handle, int maxFindLength);
|
||
|
||
/**
|
||
* 查找下一个黑标
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_BlackMark_FindNextBlackMark(Pointer handle);
|
||
|
||
/**
|
||
* 黑标模式下,设置起始打印位置的调整值
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param position 大于 0 则指定为进纸,小于 0 则指定为退纸。距离为 position x 0.125 毫米。
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_BlackMark_SetBlackMarkPaperPrintPosition(Pointer handle, int position);
|
||
|
||
/**
|
||
* 黑标模式下,设置切纸位置
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param position 大于 0 则指定为进纸,小于 0 则指定为退纸。距离为 position x 0.125 毫米。
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_BlackMark_SetBlackMarkPaperCutPosition(Pointer handle, int position);
|
||
|
||
/**
|
||
* 切刀全切
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_BlackMark_FullCutBlackMarkPaper(Pointer handle);
|
||
|
||
/**
|
||
* 切刀半切
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_BlackMark_HalfCutBlackMarkPaper(Pointer handle);
|
||
|
||
/**
|
||
* 启用标签模式
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_EnableLabelMode(Pointer handle);
|
||
|
||
/**
|
||
* 关闭标签模式
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_DisableLabelMode(Pointer handle);
|
||
|
||
/**
|
||
* 校准标签纸(更换不同规格标签纸,需要校准)
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_CalibrateLabel(Pointer handle);
|
||
|
||
/**
|
||
* 走纸到标签缝隙处
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_FeedLabel(Pointer handle);
|
||
|
||
/**
|
||
* 指示一个标签页面的开始,并设置标签页的大小,参考点坐标和页面旋转角度
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 页面起始点 x 坐标
|
||
* @param y 页面起始点 y 坐标
|
||
* @param width 页面页宽
|
||
* @param height 页面页高
|
||
* @param rotation 页面旋转。取值范围为{0,1}。为 0,页面不旋转打印,为 1,页面旋转 90 度打印。
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_PageBegin(Pointer handle, int x, int y, int width, int height, int rotation);
|
||
|
||
/**
|
||
* 将标签页上的内容打印到标签纸上
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param copies 份数 [ 1 - 255 ]
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_PagePrint(Pointer handle, int copies);
|
||
|
||
/**
|
||
* 在标签页面上指定位置绘制文本。只能单行打印。
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 定义文本起始位置 x 坐标,取值范围:[0, Page_Width-1]
|
||
* @param y 定义文本起始位置 y 坐标,取值范围:[0, Page_Height-1]
|
||
* @param font 选择字体,可以使用 24。带矢量字机型支持 16,[20,99]。
|
||
* @param style 字符风格。
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_DrawText(Pointer handle, int x, int y, int font, int style, String str);
|
||
|
||
/**
|
||
* 在标签页面上指定位置绘制文本。只能单行打印。
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 定义文本起始位置 x 坐标,取值范围:[0, Page_Width-1]
|
||
* @param y 定义文本起始位置 y 坐标,取值范围:[0, Page_Height-1]
|
||
* @param font 选择字体,可以使用 24。带矢量字机型支持 16,[20,99]。
|
||
* @param style 字符风格。
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
* 该函数会将数据转为 UTF8 编码发送。
|
||
*/
|
||
boolean CP_Label_DrawTextInUTF8(Pointer handle, int x, int y, int font, int style, WString str);
|
||
|
||
/**
|
||
* 在标签页面上指定位置绘制文本。只能单行打印。
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 定义文本起始位置 x 坐标,取值范围:[0, Page_Width-1]
|
||
* @param y 定义文本起始位置 y 坐标,取值范围:[0, Page_Height-1]
|
||
* @param font 选择字体,可以使用 24。带矢量字机型支持 16,[20,99]。
|
||
* @param style 字符风格。
|
||
* @param str 要打印的字符串
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
* 该函数会将数据转为 GBK 编码发送。
|
||
*/
|
||
boolean CP_Label_DrawTextInGBK(Pointer handle, int x, int y, int font, int style, WString str);
|
||
|
||
/**
|
||
* 在标签页指定位置绘制一维条码。
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 条码左上角 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
* @param y 条码左上角 y 坐标值,取值范围:[0, Page_Height-1]。
|
||
* @param nBarcodeType 标识条码类型
|
||
* @param nBarcodeTextPrintPosition 条码可读字符位置,取值范围:[0, 3]。
|
||
* @param height 定义条码高度。
|
||
* @param unitwidth 定义码块单元宽度。取值范围:[1, 4]。
|
||
* @param rotation 表示旋转角度。取值范围:[0, 3]。
|
||
* @param str 要打印的条码
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_DrawBarcode(Pointer handle, int x, int y, int nBarcodeType, int nBarcodeTextPrintPosition, int height, int unitwidth, int rotation, String str);
|
||
|
||
/**
|
||
* 在标签页指定位置绘制 QR 码。
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 左上角 x 坐标值,取值范围:[0,Page_Width-1]。
|
||
* @param y 左上角 y 坐标值,取值范围:[0, Page_Height-1]。
|
||
* @param nVersion 指定字符版本。取值范围:[0,16]。
|
||
* @param nECCLevel 指定纠错等级。取值范围:[1, 4]。
|
||
* @param unitwidth 定义码块单元宽度。取值范围:[1, 4]。
|
||
* @param rotation 表示旋转角度。取值范围:[0, 3]。
|
||
* @param str 要打印的 QR 码
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_DrawQRCode(Pointer handle, int x, int y, int nVersion, int nECCLevel, int unitwidth, int rotation, String str);
|
||
|
||
/**
|
||
* 在标签页指定位置绘制 PDF417 条码
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 左上角 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
* @param y 左上角 y 坐标值,取值范围:[0, Page_Height-1]。
|
||
* @param column ColNum 为列数,表述每行容纳多少码字。
|
||
* @param nAspectRatio 指定纵横比。
|
||
* @param nECCLevel 指定纠错等级。取值范围:[0, 8]。
|
||
* @param unitwidth 定义码块单元宽度。取值范围:[1, 3]。
|
||
* @param rotation 表示旋转角度。取值范围:[0, 3]。
|
||
* @param str 要打印的 PDF417 码
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_DrawPDF417Code(Pointer handle, int x, int y, int column, int nAspectRatio, int nECCLevel, int unitwidth, int rotation, String str);
|
||
|
||
/**
|
||
* 在标签页指定位置绘制位图
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 左上角 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
* @param y 左上角 y 坐标值,取值范围:[0, Page_Height-1]。
|
||
* @param dstw 要打印的宽度
|
||
* @param dsth 要打印的高度
|
||
* @param pszFile 图片的路径
|
||
* @param binaryzation_method 图片二值化算法。
|
||
* @param compression_method 最终打印数据的压缩方式。
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_DrawImageFromFile(Pointer handle, int x, int y, int dstw, int dsth, String pszFile, int binaryzation_method, int compression_method);
|
||
|
||
/**
|
||
* 在标签页指定位置绘制位图
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 左上角 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
* @param y 左上角 y 坐标值,取值范围:[0, Page_Height-1]。
|
||
* @param dstw 要打印的宽度
|
||
* @param dsth 要打印的高度
|
||
* @param data 图片数据。
|
||
* @param data_size 图片数据长度
|
||
* @param binaryzation_method 图片二值化算法。
|
||
* @param compression_method 最终打印数据的压缩方式。
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
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);
|
||
|
||
/**
|
||
* 在标签页指定位置绘制位图
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 左上角 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
* @param y 左上角 y 坐标值,取值范围:[0, Page_Height-1]。
|
||
* @param img_data 图片的像素数据。
|
||
* @param img_datalen 图片的像素数据字节数。
|
||
* @param img_width 图片的像素宽度。
|
||
* @param img_height 图片的像素高度。
|
||
* @param img_stride 图片水平跨度。表示每行字节数。
|
||
* @param binaryzation_method 图片二值化算法。
|
||
* @param compression_method 最终打印数据的压缩方式。
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
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 binaryzation_method, int compression_method);
|
||
|
||
/**
|
||
* 在标签页指定位置绘制线段
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param startx 直线段起始点 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
* @param starty 直线段起始点 y 坐标值,取值范围:[0,Page_Height-1]。
|
||
* @param endx 直线段终止点 x 坐标值,取值范围:[0, Page_Width-1]。
|
||
* @param endy 直线段终止点 y 坐标值,取值范围:[0,Page_Height-1]。
|
||
* @param linewidth 直线段线宽,取值范围:[1,Page_Height-1]。
|
||
* @param linecolor 直线段颜色线条颜色,0 是白色,1 是黑色
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_DrawLine(Pointer handle, int startx, int starty, int endx, int endy, int linewidth, int linecolor);
|
||
|
||
/**
|
||
* 在标签页指定位置绘制矩形
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param width 矩形宽度
|
||
* @param height 矩形高度
|
||
* @param color 矩形颜色,0 是白色,1 是黑色
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_DrawRect(Pointer handle, int x, int y, int width, int height, int color);
|
||
|
||
/**
|
||
* 在标签页指定位置绘制矩形框
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param x 横向坐标
|
||
* @param y 纵向坐标
|
||
* @param width 矩形框宽度
|
||
* @param height 矩形框高度
|
||
* @param borderwidth 矩形框边框宽度
|
||
* @param bordercolor 矩形框边框颜色,0 是白色,1 是黑色
|
||
* @return 返回值仅指示指令是否写入成功。返回 true 表示写入成功,返回 false 表示写入失败。
|
||
*/
|
||
boolean CP_Label_DrawBox(Pointer handle, int x, int y, int width, int height, int borderwidth, int bordercolor);
|
||
|
||
/**
|
||
* 查询电池电量
|
||
* 仅部分带电池的机型支持该指令
|
||
*
|
||
* @param handle 端口句柄,由 OpenXXX 返回
|
||
* @param timeout 超时毫秒时间。查询等待时间不超过此时间。
|
||
* @return 返回电池电量,范围在 0-100 之间。返回 -1 表示查询失败。
|
||
*/
|
||
int CP_Proto_QueryBatteryLevel(Pointer handle, int timeout);
|
||
|
||
public static class CP_Label_DrawImageFromData_Helper {
|
||
public CP_Label_DrawImageFromData_Helper() {
|
||
}
|
||
|
||
public static boolean DrawImageFromBufferedImage(Pointer handle, int x, int y, int dstw, int dsth, BufferedImage image, int binaryzation_method, int compression_method) {
|
||
boolean result = false;
|
||
|
||
try {
|
||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||
ImageIO.write(image, "png", os);
|
||
byte[] data = os.toByteArray();
|
||
result = AutoReplyPrint.INSTANCE.CP_Label_DrawImageFromData(handle, x, y, dstw, dsth, data, data.length, binaryzation_method, compression_method);
|
||
} catch (Throwable var11) {
|
||
var11.printStackTrace();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
}
|
||
|
||
public static 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;
|
||
}
|
||
|
||
if (underline) {
|
||
style |= 2;
|
||
}
|
||
|
||
if (highlight) {
|
||
style |= 4;
|
||
}
|
||
|
||
if (strikethrough) {
|
||
style |= 8;
|
||
}
|
||
|
||
style |= rotation << 4;
|
||
style |= widthscale << 8;
|
||
style |= heightscale << 12;
|
||
this.style = style;
|
||
}
|
||
|
||
public int getStyle() {
|
||
return this.style;
|
||
}
|
||
}
|
||
|
||
public interface CP_OnBluetoothDeviceDiscovered_Callback extends Callback {
|
||
void CP_OnBluetoothDeviceDiscovered(String var1, String var2, Pointer var3);
|
||
}
|
||
|
||
public interface CP_OnNetPrinterDiscovered_Callback extends Callback {
|
||
void CP_OnNetPrinterDiscovered(String var1, String var2, String var3, String var4, Pointer var5);
|
||
}
|
||
|
||
public interface CP_OnPortClosedEvent_Callback extends Callback {
|
||
void CP_OnPortClosedEvent(Pointer var1, Pointer var2);
|
||
}
|
||
|
||
public interface CP_OnPortOpenFailedEvent_Callback extends Callback {
|
||
void CP_OnPortOpenFailedEvent(Pointer var1, String var2, Pointer var3);
|
||
}
|
||
|
||
public interface CP_OnPortOpenedEvent_Callback extends Callback {
|
||
void CP_OnPortOpenedEvent(Pointer var1, String var2, Pointer var3);
|
||
}
|
||
|
||
public interface CP_OnPortReceivedEvent_Callback extends Callback {
|
||
void CP_OnPortReceivedEvent(Pointer var1, Pointer var2, int var3, Pointer var4);
|
||
}
|
||
|
||
public interface CP_OnPortWrittenEvent_Callback extends Callback {
|
||
void CP_OnPortWrittenEvent(Pointer var1, Pointer var2, int var3, Pointer var4);
|
||
}
|
||
|
||
public interface CP_OnPrinterPrintedEvent_Callback extends Callback {
|
||
void CP_OnPrinterPrintedEvent(Pointer var1, int var2, Pointer var3);
|
||
}
|
||
|
||
public interface CP_OnPrinterReceivedEvent_Callback extends Callback {
|
||
void CP_OnPrinterReceivedEvent(Pointer var1, int var2, Pointer var3);
|
||
}
|
||
|
||
public interface CP_OnPrinterStatusEvent_Callback extends Callback {
|
||
void CP_OnPrinterStatusEvent(Pointer var1, long var2, long var4, Pointer var6);
|
||
}
|
||
|
||
public static class CP_Page_DrawRasterImageFromData_Helper {
|
||
public CP_Page_DrawRasterImageFromData_Helper() {
|
||
}
|
||
|
||
public static boolean DrawRasterImageFromBufferedImage(Pointer handle, int x, int y, int dstw, int dsth, BufferedImage image, int binaryzation_method) {
|
||
boolean result = false;
|
||
|
||
try {
|
||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||
ImageIO.write(image, "png", os);
|
||
byte[] data = os.toByteArray();
|
||
result = AutoReplyPrint.INSTANCE.CP_Page_DrawRasterImageFromData(handle, x, y, dstw, dsth, data, data.length, binaryzation_method);
|
||
} catch (Throwable var10) {
|
||
var10.printStackTrace();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
}
|
||
|
||
public static class CP_Port_EnumCom_Helper {
|
||
public CP_Port_EnumCom_Helper() {
|
||
}
|
||
|
||
public static String[] EnumCom() {
|
||
IntByReference pcbNeeded = new IntByReference();
|
||
AutoReplyPrint.INSTANCE.CP_Port_EnumCom((byte[]) null, 0, pcbNeeded);
|
||
if (pcbNeeded.getValue() > 0) {
|
||
byte[] pBuf = new byte[pcbNeeded.getValue()];
|
||
if (pBuf != null) {
|
||
AutoReplyPrint.INSTANCE.CP_Port_EnumCom(pBuf, pBuf.length, (IntByReference) null);
|
||
String s = new String(pBuf);
|
||
String[] ss = s.split("\u0000");
|
||
return ss;
|
||
}
|
||
}
|
||
|
||
return null;
|
||
}
|
||
}
|
||
|
||
public static class CP_Port_EnumLpt_Helper {
|
||
public CP_Port_EnumLpt_Helper() {
|
||
}
|
||
|
||
public static String[] EnumLpt() {
|
||
IntByReference pcbNeeded = new IntByReference();
|
||
AutoReplyPrint.INSTANCE.CP_Port_EnumLpt((byte[]) null, 0, pcbNeeded);
|
||
if (pcbNeeded.getValue() > 0) {
|
||
byte[] pBuf = new byte[pcbNeeded.getValue()];
|
||
if (pBuf != null) {
|
||
AutoReplyPrint.INSTANCE.CP_Port_EnumLpt(pBuf, pBuf.length, (IntByReference) null);
|
||
String s = new String(pBuf);
|
||
String[] ss = s.split("\u0000");
|
||
return ss;
|
||
}
|
||
}
|
||
|
||
return null;
|
||
}
|
||
}
|
||
|
||
public static class CP_Port_EnumUsb_Helper {
|
||
public CP_Port_EnumUsb_Helper() {
|
||
}
|
||
|
||
public static String[] EnumUsb() {
|
||
IntByReference pcbNeeded = new IntByReference();
|
||
AutoReplyPrint.INSTANCE.CP_Port_EnumUsb((byte[]) null, 0, pcbNeeded);
|
||
if (pcbNeeded.getValue() > 0) {
|
||
byte[] pBuf = new byte[pcbNeeded.getValue()];
|
||
if (pBuf != null) {
|
||
AutoReplyPrint.INSTANCE.CP_Port_EnumUsb(pBuf, pBuf.length, (IntByReference) null);
|
||
String s = new String(pBuf);
|
||
String[] ss = s.split("\u0000");
|
||
return ss;
|
||
}
|
||
}
|
||
|
||
return null;
|
||
}
|
||
}
|
||
|
||
public static class CP_Pos_PrintRasterImageFromData_Helper {
|
||
public CP_Pos_PrintRasterImageFromData_Helper() {
|
||
}
|
||
|
||
public static boolean PrintRasterImageFromBufferedImage(Pointer handle, int dstw, int dsth, BufferedImage image, int binaryzation_method, int compression_method) {
|
||
boolean result = false;
|
||
|
||
try {
|
||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||
ImageIO.write(image, "png", os);
|
||
byte[] data = os.toByteArray();
|
||
result = AutoReplyPrint.INSTANCE.CP_Pos_PrintRasterImageFromData(handle, dstw, dsth, data, data.length, binaryzation_method, compression_method);
|
||
} catch (Throwable var9) {
|
||
var9.printStackTrace();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
}
|
||
|
||
public static class CP_PrinterStatus {
|
||
private long error_status = 0L;
|
||
private long info_status = 0L;
|
||
|
||
public CP_PrinterStatus(long error_status, long info_status) {
|
||
this.error_status = error_status;
|
||
this.info_status = info_status;
|
||
}
|
||
|
||
public long errorStatus() {
|
||
return this.error_status;
|
||
}
|
||
|
||
public long infoStatus() {
|
||
return this.info_status;
|
||
}
|
||
|
||
public boolean ERROR_OCCURED() {
|
||
return this.error_status != 0L;
|
||
}
|
||
|
||
public boolean ERROR_CUTTER() {
|
||
return (this.error_status & 1L) != 0L;
|
||
}
|
||
|
||
public boolean ERROR_FLASH() {
|
||
return (this.error_status & 2L) != 0L;
|
||
}
|
||
|
||
public boolean ERROR_NOPAPER() {
|
||
return (this.error_status & 4L) != 0L;
|
||
}
|
||
|
||
public boolean ERROR_VOLTAGE() {
|
||
return (this.error_status & 8L) != 0L;
|
||
}
|
||
|
||
public boolean ERROR_MARKER() {
|
||
return (this.error_status & 16L) != 0L;
|
||
}
|
||
|
||
public boolean ERROR_ENGINE() {
|
||
return (this.error_status & 32L) != 0L;
|
||
}
|
||
|
||
public boolean ERROR_OVERHEAT() {
|
||
return (this.error_status & 64L) != 0L;
|
||
}
|
||
|
||
public boolean ERROR_COVERUP() {
|
||
return (this.error_status & 128L) != 0L;
|
||
}
|
||
|
||
public boolean ERROR_MOTOR() {
|
||
return (this.error_status & 256L) != 0L;
|
||
}
|
||
|
||
public boolean INFO_LABELPAPER() {
|
||
return (this.info_status & 2L) != 0L;
|
||
}
|
||
|
||
public boolean INFO_LABELMODE() {
|
||
return (this.info_status & 4L) != 0L;
|
||
}
|
||
|
||
public boolean INFO_HAVEDATA() {
|
||
return (this.info_status & 8L) != 0L;
|
||
}
|
||
|
||
public boolean INFO_NOPAPERCANCELED() {
|
||
return (this.info_status & 16L) != 0L;
|
||
}
|
||
|
||
public boolean INFO_PAPERNOFETCH() {
|
||
return (this.info_status & 32L) != 0L;
|
||
}
|
||
|
||
public boolean INFO_PRINTIDLE() {
|
||
return (this.info_status & 64L) != 0L;
|
||
}
|
||
|
||
public boolean INFO_RECVIDLE() {
|
||
return (this.info_status & 128L) != 0L;
|
||
}
|
||
}
|
||
|
||
public static class CP_Printer_GetPrinterFirmwareVersion_Helper {
|
||
public CP_Printer_GetPrinterFirmwareVersion_Helper() {
|
||
}
|
||
|
||
public static String GetPrinterFirmwareVersion(Pointer handle) {
|
||
IntByReference pcbNeeded = new IntByReference();
|
||
AutoReplyPrint.INSTANCE.CP_Printer_GetPrinterFirmwareVersion(handle, (byte[]) null, 0, pcbNeeded);
|
||
if (pcbNeeded.getValue() > 0) {
|
||
byte[] pBuf = new byte[pcbNeeded.getValue()];
|
||
if (pBuf != null) {
|
||
AutoReplyPrint.INSTANCE.CP_Printer_GetPrinterFirmwareVersion(handle, pBuf, pBuf.length, (IntByReference) null);
|
||
String s = new String(pBuf);
|
||
return s;
|
||
}
|
||
}
|
||
|
||
return null;
|
||
}
|
||
}
|
||
|
||
public static class CP_RTSTATUS_Helper {
|
||
public CP_RTSTATUS_Helper() {
|
||
}
|
||
|
||
public static boolean CP_RTSTATUS_DRAWER_OPENED(long status) {
|
||
return (status >> 0 & 4L) == 0L;
|
||
}
|
||
|
||
public static boolean CP_RTSTATUS_OFFLINE(long status) {
|
||
return (status >> 0 & 8L) == 8L;
|
||
}
|
||
|
||
public static boolean CP_RTSTATUS_COVERUP(long status) {
|
||
return (status >> 8 & 4L) == 4L;
|
||
}
|
||
|
||
public static boolean CP_RTSTATUS_FEED_PRESSED(long status) {
|
||
return (status >> 8 & 8L) == 8L;
|
||
}
|
||
|
||
public static boolean CP_RTSTATUS_NOPAPER(long status) {
|
||
return (status >> 8 & 32L) == 32L;
|
||
}
|
||
|
||
public static boolean CP_RTSTATUS_ERROR_OCCURED(long status) {
|
||
return (status >> 8 & 64L) == 64L;
|
||
}
|
||
|
||
public static boolean CP_RTSTATUS_CUTTER_ERROR(long status) {
|
||
return (status >> 16 & 8L) == 8L;
|
||
}
|
||
|
||
public static boolean CP_RTSTATUS_UNRECOVERABLE_ERROR(long status) {
|
||
return (status >> 16 & 32L) == 32L;
|
||
}
|
||
|
||
public static boolean CP_RTSTATUS_DEGREE_OR_VOLTAGE_OVERRANGE(long status) {
|
||
return (status >> 16 & 64L) == 64L;
|
||
}
|
||
|
||
public static boolean CP_RTSTATUS_PAPER_NEAREND(long status) {
|
||
return (status >> 24 & 12L) == 12L;
|
||
}
|
||
|
||
public static boolean CP_RTSTATUS_PAPER_TAKEOUT(long status) {
|
||
return (status >> 24 & 4L) == 4L;
|
||
}
|
||
}
|
||
|
||
public static class GetLibraryPath_Helper {
|
||
public GetLibraryPath_Helper() {
|
||
}
|
||
|
||
private static String GetLibraryPath() {
|
||
// if (Platform.isWindows()) {
|
||
// return Platform.is64Bit() ? "/autoreplyprint/win64/autoreplyprint.dll" : "/autoreplyprint/win32/autoreplyprint.dll";
|
||
// } else if (Platform.isLinux()) {
|
||
// return Platform.is64Bit() ? "/autoreplyprint/linux-x64/libautoreplyprint.so" : "/autoreplyprint/linux-x86/libautoreplyprint.so";
|
||
// } else {
|
||
// return Platform.isMac() ? "/autoreplyprint/mac/libautoreplyprint.so" : "autoreplyprint";
|
||
// }
|
||
// 统一采用win32的autoreplyprint.dll文件
|
||
return "autoreplyprint.dll";
|
||
}
|
||
}
|
||
}
|