更新记录

1.0.1(2024-02-28)

添加接口用于打印多国语言文字,同时支持水平线性布局排版打印。
具体参考接口说明:ESC_PrintTextImageUsingHorizontalLinearLayout

1.0.0(2024-01-27)

支持ESC/POS指令打印,文本、条码、二维码、图片
支持读写指令接口,可写任意指令(包括16进制指令和文本指令),可支持TSPL CPCL ZPL EPL 等指令集
支持各种端口,TCP,蓝牙SPP,蓝牙BLE,USB,串口
通讯功能非常稳定好用,接口也非常齐全和合理
基本流程就是打开端口,写各种指令,打印各种内容,设置各种格式


平台兼容性

Android Android CPU类型 iOS
适用版本区间:4.4 - 14.0 armeabi-v7a:支持,arm64-v8a:支持,x86:支持 ×

原生插件通用使用流程:

  1. 购买插件,选择该插件绑定的项目。
  2. 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
  3. 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
  4. 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
  5. 开发完毕后正式云打包

付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios

注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择


插件概览

通用多接口多连接热敏打印机打印插件。
封装了ESC/POS打印指令,支持文本条码二维码图片打印,支持各国语言小语种打印。
预留了读写接口,可额外支持其他指令集(比如TSPL,CPCL,ZPL,EPL等)。
支持网络(TCP)、蓝牙(SPP/BLE)、USB、串口等接口通讯。
自动缓存收取到的数据,应用程序可无阻塞直接读取数据。
部分接口能及时获知对端断开(TCP/SPP/BLE/USB)。
提供搜索接口,搜索蓝牙设备、USB设备、串口设备。
提供统一的读、写、关闭接口,不同的端口使用不同的接口和参数打开。

各项功能都经过长时间大量测试非常稳定,如果有什么疑问、建议和意见,欢迎联系QQ1147652910。
如果未能满足您的需求,欢迎联系,会尽快安排。

插件调用流程

1 获取插件实例:

    var SSPrint = uni.requireNativePlugin("wyj-ssprint_SSPrintUniModule");

2 声明端口句柄:(最好是全局的)

    var handle = 0;  

3 打开端口:(判断端口是否已打开,如果没有打开才需要打开,如果已经打开了则跳过这一步)
例如:

    open_port_if_not_opened() {
        //如果有端口未关闭,则直接使用之前未关闭的端口。
        //这个调试的时候用会比较方便,实际使用的时候,需要自己管理好句柄。
        if (!SSPrint.Port_IsOpened(handle)) {
            var handleList = SSPrint.Port_GetPortHandleList();
            for (let i = 0; i < handleList.length; i++) {
                if (SSPrint.Port_IsOpened(handleList[i])) {
                    var infoMap = SSPrint.Port_GetPortInfoMap(handleList[i]);
                    this.message = infoMap;

                    handle = handleList[i];
                    modal.toast({
                        message: "先前有未关闭的端口,已自动选择之前所使用的端口",
                        duration: 1.5
                    });

                    return;
                } 
            }
        }

        //如果端口未打开,则打开端口。
        if (!SSPrint.Port_IsOpened(handle)) {
            this.message = "正在打开端口...";
            modal.toast({
                message: "正在打开端口...",
                duration: 1.5
            });
            var matchingInfoMap = new Map();
            matchingInfoMap["ProductName"] = this.deviceArray[this.deviceIndex];
            handle = SSPrint.Port_OpenUsb(matchingInfoMap);
            if (SSPrint.Port_IsOpened(handle)) {
                this.message = "端口打开成功";

                var portInfo = SSPrint.Port_GetPortInfoMap(handle);
                modal.toast({
                    message: portInfo,
                    duration: 1.5
                });
            } else {
                this.message = "端口打开失败";
            }
        }
    },  

4 写数据/读数据/其他业务逻辑
例如:

    this.message = "正在写入...";
    modal.toast({
        message: "正在写入...",
        duration: 1.5
    });
    var cmd = new Uint8Array([0x10, 0x04, 0x04, 0x30, 0x31, 0x32, 0x0D, 0x0A]);
    if (SSPrint.Port_WriteBytesFromBase64String(handle, uni.arrayBufferToBase64(cmd)) <= 0) {
        this.message = "写入失败";
        return;
    }
    this.message = "写入成功";

    var bytesBase64String = SSPrint.Port_ReadBytesToBase64String(handle, 0x100);
    var bytes = new Uint8Array(uni.base64ToArrayBuffer(bytesBase64String));
    if (bytes.length > 0) {
        var str = "读取字节数:" + bytes.length + "\r\n";
        for (let i = 0; i < bytes.length; i++) {
            var hex = bytes[i].toString(16);
            if (hex.length == 1)
                hex = "0" + hex;
            str += hex;
            str += " ";
        }
        str += "\r\n";
        this.message = str;
    } else {
        this.message = "无数据可读";
    }

5 关闭端口(或不关闭端口)
如果应用独占端口,则可以不用关闭端口,下次使用的时候直接用已有的句柄handle去操作。
如果是写完数据立刻关闭,部分端口可能需要延时,具体请看例子,里面每个接口都有测试例子,很详细。

    if (SSPrint.Port_IsOpened(handle)) {
        this.message = "正在关闭端口...";
        SSPrint.Port_Close(handle);
        this.message = "端口已关闭";
    }

6 打印内容(ESC指令打印,文本、条码、二维码、图片)

test_print_esc() {
    this.open_port_if_not_opened();
    if (!SSPrint.Port_IsOpened(handle))
        return;

    //初始化打印机,避免之前残留的格式设置影响打印效果。
    SSPrint.ESC_InitializePrinter(handle);

    //文本编码,打印机自册页上一般会显示打印机的默认编码。一般是UTF-8或GBK。
    var encoding = "UTF-8";
    //var encoding = "GBK";

    //文本格式,支持宽度放大,高度放大,加粗,下划线。
    SSPrint.ESC_PrintText(handle, "123456789\n", encoding, 0, 0, 0, 0);
    SSPrint.ESC_PrintText(handle, "123456789\n", encoding, 1, 0, 0, 0);
    SSPrint.ESC_PrintText(handle, "123456789\n", encoding, 1, 1, 0, 0);
    SSPrint.ESC_PrintText(handle, "123456789\n", encoding, 1, 1, 1, 0);
    SSPrint.ESC_PrintText(handle, "123456789\n", encoding, 1, 1, 1, 1);
    SSPrint.ESC_PrintText(handle, "hello world! 你好 世界!\n", encoding, 0, 0, 0, 0);
    SSPrint.ESC_PrintText(handle, "hello world! 你好 世界!\n", encoding, 1, 1, 1, 1);

    //文本列表
    SSPrint.ESC_PrintText(handle, "--------------------------------\n", encoding, 0, 0, 0, 0);
    SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 0);
    SSPrint.ESC_PrintText(handle, "T0", encoding, 0, 0, 0, 0);
    SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 60);
    SSPrint.ESC_PrintText(handle, "T1", encoding, 0, 0, 0, 0);
    SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 120);
    SSPrint.ESC_PrintText(handle, "T2", encoding, 0, 0, 0, 0);
    SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 180);
    SSPrint.ESC_PrintText(handle, "T3", encoding, 0, 0, 0, 0);
    SSPrint.ESC_PrintAndFeedPaperOneLine(handle);
    SSPrint.ESC_PrintText(handle, "================================\n", encoding, 0, 0, 0, 0);
    SSPrint.ESC_PrintAndFeedPaperMultipleDots(handle, 10);
    for (let i = 0; i < 5; i++) {
        SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 0);
        SSPrint.ESC_PrintText(handle, "D"+i+"0", encoding, 0, 0, 0, 0);
        SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 60);
        SSPrint.ESC_PrintText(handle, "D"+i+"1", encoding, 0, 0, 0, 0);
        SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 120);
        SSPrint.ESC_PrintText(handle, "D"+i+"2", encoding, 0, 0, 0, 0);
        SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 180);
        SSPrint.ESC_PrintText(handle, "D"+i+"3", encoding, 0, 0, 0, 0);
        SSPrint.ESC_PrintAndFeedPaperOneLine(handle);
    }
    SSPrint.ESC_PrintText(handle, "================================\n", encoding, 0, 0, 0, 0);
    SSPrint.ESC_PrintAndFeedPaperMultipleLines(handle, 2);
    SSPrint.ESC_PrintText(handle, "================================\n", encoding, 0, 0, 0, 0);

    //水平相对位置
    SSPrint.ESC_PrintText(handle, "A00", encoding, 0, 0, 0, 0);
    SSPrint.ESC_SetHorizontalRelativePrintPosition(handle, 12);
    SSPrint.ESC_PrintText(handle, "B001", encoding, 0, 0, 0, 0);
    SSPrint.ESC_SetHorizontalRelativePrintPosition(handle, 12);
    SSPrint.ESC_PrintText(handle, "C0", encoding, 0, 0, 0, 0);
    SSPrint.ESC_SetHorizontalRelativePrintPosition(handle, 12);
    SSPrint.ESC_PrintText(handle, "D0", encoding, 0, 0, 0, 0);
    SSPrint.ESC_PrintAndFeedPaperOneLine(handle);

    //对齐方式,对之后的文本、条码、二维码、图片都有效。0左对齐,1中对齐,2右对齐。
    SSPrint.ESC_SelectJustification(handle, 0);
    SSPrint.ESC_PrintText(handle, "Left\n", encoding, 0, 0, 0, 0);
    SSPrint.ESC_SelectJustification(handle, 1);
    SSPrint.ESC_PrintText(handle, "Center\n", encoding, 0, 0, 0, 0);
    SSPrint.ESC_SelectJustification(handle, 2);
    SSPrint.ESC_PrintText(handle, "Right\n", encoding, 0, 0, 0, 0);
    SSPrint.ESC_SelectJustification(handle, 0);
    SSPrint.ESC_PrintText(handle, "Left\n", encoding, 0, 0, 0, 0);

    //设置行高
    SSPrint.ESC_SetLineHeight(handle, 30);
    for (let i = 0; i < 3; i++) {
        SSPrint.ESC_PrintText(handle, "LineHeight 30\n", encoding, 0, 0, 0, 0);
    }
    SSPrint.ESC_SetLineHeight(handle, 60);
    for (let i = 0; i < 3; i++) {
        SSPrint.ESC_PrintText(handle, "LineHeight 60\n", encoding, 0, 0, 0, 0);
    }
    SSPrint.ESC_SetLineHeight(handle, 90);
    for (let i = 0; i < 3; i++) {
        SSPrint.ESC_PrintText(handle, "LineHeight 90\n", encoding, 0, 0, 0, 0);
    }
    SSPrint.ESC_SetLineHeight(handle, 30);

    //设置打印区域
    SSPrint.ESC_SetPrintAreaLeftMargin(handle, 24);
    SSPrint.ESC_SetPrintAreaWidth(handle, 300);
    SSPrint.ESC_PrintText(handle, "12345678901234567890123456789012\n", encoding, 0, 0, 0, 0);
    //恢复设置
    SSPrint.ESC_InitializePrinter(handle);

    //打印条码
    //UPCA:65   有效字符11个,第12个字符是校验,自动生成。
    SSPrint.ESC_PrintBarcode(handle, "12345678901", 65, 2, 40, 0, 2);
    //UPCE:66   有效字符6个,第7个字符是校验,自动生成。
    SSPrint.ESC_PrintBarcode(handle, "123456", 66, 2, 40, 0, 2);
    //EAN13:67  有效字符12个,第13个字符是校验,自动生成。
    SSPrint.ESC_PrintBarcode(handle, "123456789012", 67, 2, 40, 0, 2);
    //EAN8:68   有效字符7个,第8个字符是校验,自动生成。
    SSPrint.ESC_PrintBarcode(handle, "1234567", 68, 2, 40, 0, 2);
    //CODE39:69 
    SSPrint.ESC_PrintBarcode(handle, "123456", 69, 2, 40, 0, 2);
    //ITF:70    偶数个字符
    SSPrint.ESC_PrintBarcode(handle, "123456", 70, 2, 40, 0, 2);
    //CODABAR:71
    SSPrint.ESC_PrintBarcode(handle, "A123456A", 71, 2, 40, 0, 2);
    //CODE93:72
    SSPrint.ESC_PrintBarcode(handle, "123456", 72, 2, 40, 0, 2);
    //CODE128:73 一般以"{B"开头
    SSPrint.ESC_PrintBarcode(handle, "{B" + "No.123456", 73, 2, 40, 0, 2)

    //打印二维码 单元宽度1-16 纠错等级48:L 49:M 50:Q 51:H
    SSPrint.ESC_PrintQRCode(handle, "hello world! 你好 世界!", 8, 48);

    //开钱箱
    //SSPrint.ESC_KickOutDrawer(handle);

    //切刀,全切就是直接切断,半切大概留2mm不切。
    //SSPrint.ESC_FeedsPaperToCuttingPositionAndFullCut(handle);
    //SSPrint.ESC_FeedsPaperToCuttingPositionAndPartialCut(handle);
},
test_print_image() {
    uni.chooseImage({
        count: 1, //默认9
        sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
        sourceType: ['album'], //从相册选择
        success: function (res) {
            console.log(res.tempFilePaths[0]);
            //打印图片 
            //打印模式 0:原尺寸打印 1:倍宽打印 2:倍高打印 3:倍宽倍高打印 大于等于8时:按照指定宽度打印
            //SSPrint.ESC_PrintImage(handle, res.tempFilePaths[0], 0);
            //SSPrint.ESC_PrintImage(handle, res.tempFilePaths[0], 1);
            //SSPrint.ESC_PrintImage(handle, res.tempFilePaths[0], 2);
            //SSPrint.ESC_PrintImage(handle, res.tempFilePaths[0], 3);
            SSPrint.ESC_PrintImage(handle, res.tempFilePaths[0], 384);
        }
    });
},

7 打印多国语言内容

generate_item_map(x, width, text, horizontalAlignment, textSize, bold, underline) {
    var itemMap = new Map();
    itemMap["x"] = "" + x;
    itemMap["width"] = "" + width;
    itemMap["text"] = "" + text;
    itemMap["horizontalAlignment"] = "" + horizontalAlignment;
    itemMap["textSize"] = "" + textSize;
    itemMap["bold"] = "" + bold;
    itemMap["underline"] = "" + underline;
    return itemMap;
},
test_print_multilingual() {
    this.open_port_if_not_opened();
    if (!SSPrint.Port_IsOpened(handle))
        return;

    //打印标题
    if (1) {
        var itemMapList = new Array();
        //标题只有一列,可以占满整个宽度,居中打印。
        itemMapList.push(this.generate_item_map(0,384,"多语言测试单据","CENTER",36,true,true));
        //按照水平线性布局打印文字
        //参数分别是:
        //  布局宽度(必须大于0)
        //  布局高度(可以等于0表示自动适应)
        //  垂直对齐(多列内容高度不一的时候有用)
        //  内容列表(列表中的每个内容,都有位置,宽度,水平对齐,等属性)
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);
    }

    //打印第一部分内容,主要演示水平线性布局坐标和对齐的用法。
    if (1) {
        var itemMapList;

        //每一条内容,都有一个宽度,和水平对齐。内容小于宽度的时候,就会按照指定对齐方式排版。
        //多条内容高度不一样的时候,垂直对齐就会生效。

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"品名","NORMAL",28,true,false));
        itemMapList.push(this.generate_item_map(200,100,"重量","CENTER",28,true,false));
        itemMapList.push(this.generate_item_map(300,84,"金额","OPPOSITE",28,true,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"虾子","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"1.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"60元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"超级帝王蟹","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"2.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"2600元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"非常好吃的大龙虾","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"3.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"1000元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"超极品美味超级大大大龙虾","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"3000.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"123456789元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"超极品美味超级大大大帝王蟹","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"30.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"1289元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 1, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"超极品美味超级大大大面包蟹","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"30.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"1289元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 2, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"超极品美味超级大大大面包蟹","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"30.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"1289元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 100, 2, itemMapList);

    }

    //打印第二部分内容,主要演示多语言。
    if (1) {
        var itemMapList;

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,384,"人が心に抱き、信じられることは、すべて実現できる。","",28,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,384,"넌 찾아낼 거야 네 안에 있는","",28,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,384,"有一種思淰嘂嬡你","",28,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,384,"كان فى نيتى ان أتعرف عليكم منذ زمان ","",28,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,384,"อ่านสามวิธีหนึ่งคืออ่านแต่ไม่เข้าใจอ่านอีกทั้งยังเข้าใจและหนึ่งในหนังสือที่อ่านและเข้าใจในสิ่งที่พวกเขาไม่ได้","",28,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,384,"អ្នកចេះនិយាយភាសាខ្មែរទេ","",28,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

    }

    SSPrint.ESC_PrintAndFeedPaperMultipleLines(handle, 6);
}

接口列表及说明

Plugin_Version

String Plugin_Version()  

获取SSIO插件版本
可用于验证插件是否正确加载,如果能取得版本号,证明插件配置成功。

Port_OpenTcp

long Port_OpenTcp(String dest_ip, int dest_port, String local_ip, int local_port, int timeout_ms)  

打开TCP连接
dest_ip:目标IP
dest_port:目标端口
local_ip:是否绑定到特定本地IP,可不填
local_port:是否绑定到特定本地端口,可填0表示自动选择本地可用端口
timeout_ms:连接超时毫秒时间
返回端口句柄

Port_OpenBtSpp

long Port_OpenBtSpp(String address, int secure, int timeout_ms)  

打开蓝牙SPP连接
address:蓝牙地址,可以通过搜索得到蓝牙设备信息
secure:是否是安全连接,1表示安全,0表示不安全。当服务器和客户端都使用不安全连接时,SPP连接无需密码即可通讯。
timeout_ms:连接超时毫秒时间
返回端口句柄

Port_OpenBtBle

long Port_OpenBtBle(String address, int timeout_ms)  

打开蓝牙BLE连接
address:蓝牙地址,可以通过搜索得到蓝牙设备信息
timeout_ms:连接超时毫秒时间
返回端口句柄

Port_OpenUsb

long Port_OpenUsb(Map<String, String> matchingInfoMap)  

打开USB设备连接
matchingInfoMap:设备匹配信息。可任意指定一个或多个信息,匹配成功则打开对应的USB设备连接。
支持匹配的字段有:DeviceName、VendorId、ProductId、ManufacturerName、ProductName、SerialNumber、InterfaceClass、InterfaceSubclass、InterfaceProtocol。
如果无权限会自动申请权限,取得权限后会继续后续打开动作,使用方便。
返回端口句柄

Port_OpenSerialPort

long Port_OpenSerialPort(String device, int baudrate, int databits, int parity, int stopbits, int flowcontrol)  

打开串口设备连接
device:串口设备路径,比如/dev/ttyS0、/dev/ttyUSB0等。
baudrate:波特率
databits:数据位
parity:校验,支持0-无校验 1-奇校验 2-偶校验 3-标记校验 4-空白校验
stopbits:停止位 支持0-一位停止位 2-两位停止位
flowcontrol:流控制 支持0-无流控 1-XonXoff 2-RTS/CTS
返回端口句柄

Port_IsOpened

boolean Port_IsOpened(long handle)  

端口是否已打开
handle:端口句柄
备注:TCP/蓝牙/USB这三个端口能识别到对端断开。串口和UDP识别不到。

Port_Close

void Port_Close(long handle)  

关闭端口
handle:端口句柄
备注:如果端口不用了,要记得关闭端口。如果不关闭端口,并且也不保存句柄handle。
那么那个端口就相当于内部已经打开了,但是外面无法访问到,会有问题的。

Port_GetPortHandleList

List<Long> Port_GetPortHandleList()  

获取端口句柄列表

Port_GetPortInfoMap

Map<String, String> Port_GetPortInfoMap(long handle)  

获取端口信息
handle:端口句柄

Port_WriteBytesFromBase64String

int Port_WriteBytesFromBase64String(long handle, String bytesBase64String)  

写字节数组,但是字节数组无法作为参数直接传递给插件模块,因此字节数组从Base64String转过来
handle:端口句柄
bytesBase64String:字节数组base64字符串
返回写入的字节数,返回-1表示写入失败。

Port_WriteStringUsingEncoding

int Port_WriteStringUsingEncoding(long handle, String str, String encoding)  

将字符串按照指定编码发送
handle:端口句柄
str:要发送的字符串
encoding:指定的编码
返回写入的字节数,返回-1表示写入失败。
备注:可通过Encoding_GetAvailableEncodingList接口获取编码列表

Port_WriteStringUsingUTF8Encoding

int Port_WriteStringUsingUTF8Encoding(long handle, String str)  

将字符串按照UTF8编码发送

Port_WriteStringUsingGBKEncoding

int Port_WriteStringUsingGBKEncoding(long handle, String str)  

将字符串按照GBK编码发送

Port_WriteStringUsingBig5Encoding

int Port_WriteStringUsingBig5Encoding(long handle, String str)  

将字符串按照Big5编码发送

Port_ReadBytesToBase64String

String Port_ReadBytesToBase64String(long handle, int byteCountToRead)  

读字节数组,但是字节数组不能作为结果直接返回,那字节数组怎么传出去?字节数组转成Base64String传出去。
handle:端口句柄
byteCountToRead:要读取的字节数
返回字节数组base64字符串,调用者需解码得到原始字节数组,如下:

var bytesBase64String = SSPrint.Port_ReadBytesToBase64String(handle, 0x100);  
var bytes = new Uint8Array(uni.base64ToArrayBuffer(bytesBase64String));  
if (bytes.length > 0) {  
    var str = "读取字节数:" + bytes.length + "\r\n";  
    for (let i = 0; i < bytes.length; i++) {  
        var hex = bytes[i].toString(16);  
        if (hex.length == 1)  
            hex = "0" + hex;  
        str += hex;  
        str += " ";  
    }  
    str += "\r\n";  
    this.message = str;  
} else {  
    this.message = "无数据可读";  
}  

Port_BtBle_SetWriteCharacteristic

boolean Port_BtBle_SetWriteCharacteristic(long handle, String characteristicUUIDString)  

指定BLE写属性
handle:端口句柄
characteristicUUIDString:属性UUID

Port_BtBle_EnableCharacteristicNotification

boolean Port_BtBle_EnableCharacteristicNotification(long handle, String characteristicUUIDString)  

启用BLE属性通知,只有启用了属性通知,才能自动收到对端传来的数据。
handle:端口句柄
characteristicUUIDString:属性UUID

Port_BtBle_GetCharacteristicListWithWriteProperty

List<String> Port_BtBle_GetCharacteristicListWithWriteProperty(long handle)  

获取BLE写属性列表
handle:端口句柄

Port_BtBle_GetCharacteristicListWithNotifyProperty

List<String> Port_BtBle_GetCharacteristicListWithNotifyProperty(long handle)  

获取BLE通知属性列表
handle:端口句柄

Port_SerialPort_GetModemStatus

Map<String, String> Port_SerialPort_GetModemStatus(long handle)  

获取串口Modem状态
handle:端口句柄

SerialPort_GetDeviceList

List<String> SerialPort_GetDeviceList()  

获取串口设备列表

BluetoothAdapter_HasBluetoothPermissions

boolean BluetoothAdapter_HasBluetoothPermissions()  

检查是否有蓝牙权限,如果没有蓝牙权限,则搜不到蓝牙并且连不上蓝牙设备

BluetoothAdapter_RequestBluetoothPermissions

void BluetoothAdapter_RequestBluetoothPermissions(int requestCode)   

请求蓝牙权限
requestCode:activity回调用的,可以随便填。比如11111。

BluetoothAdapter_GetBondedDevices

List<Map<String, String>> BluetoothAdapter_GetBondedDevices()  

获得蓝牙已配对设备列表

BluetoothAdapter_GetDiscoveredDevices

List<Map<String, String>> BluetoothAdapter_GetDiscoveredDevices()  

获得蓝牙已搜索设备列表

BluetoothAdapter_ClearDiscoveredDevices

void BluetoothAdapter_ClearDiscoveredDevices()  

清除蓝牙已搜索设备列表

BluetoothAdapter_IsDiscovering

boolean BluetoothAdapter_IsDiscovering()  

蓝牙是否在搜索中

BluetoothAdapter_StartDiscovery

boolean BluetoothAdapter_StartDiscovery(final UniJSCallback deviceFoundCallback, final UniJSCallback discoveryFinishedCallback)  

开始搜索蓝牙设备
deviceFoundCallback:搜到设备回调
discoveryFinishedCallback:搜索结束回调(搜索一般是12秒)

UsbManager_GetUsbDevices

List<Map<String, Object>> UsbManager_GetUsbDevices()  

获取USB设备列表

Misc_GetAvailableEncodingList

List<String> Misc_GetAvailableEncodingList()  

获取可用字符编码列表

Misc_SleepMs

void Misc_SleepMs(int ms)  

延时一段时间

ESC_PrintText

boolean ESC_PrintText(long handle, String text, String encoding, int widthEnlarge, int heightEnlarge, boolean bold, boolean underline)

打印文本。注意文本尾部需要加换行符才会实际打印出来,比如"abc\n"。
handle:端口句柄
text:文本内容
encoding:打印文本所选的编码,会将文本按照指定的编码转成字节数组。比如:UTF-8,GBK,Big5等。
widthEnlarge:宽度放大,参数范围0-7。0表示不放大,1表示额外放大1倍,依此类推。
heightEnlarge:高度放大,参数范围0-7。0表示不放大,1表示额外放大1倍,依此类推。
bold:加粗
underline:下划线

ESC_PrintTextImageUsingHorizontalLinearLayout

boolean ESC_PrintTextImageUsingHorizontalLinearLayout(long handle, int layoutWidth, int layoutHeight, int verticalAlignment, List<Map<String, String>> itemMapList)

打印文本图像。支持一次性打印多个文本,按照水平线性布局排列打印出来。
handle:端口句柄
layoutWidth:布局宽度,必须大于0。一般58mm打印机可打印点数是384点,80mm打印机可打印点数是576点。
layoutHeight:布局高度。0表示自动适应,大于0表示所有的内容均绘制在限定高度内。
itemMapList:要打印的内容列表
每个内容里面,都有文本,坐标,宽度,对齐,字号,等格式
例如:
x:横坐标
width:内容宽度
text:内容文本
horizontalAlignment:内容水平对齐,可选"NORMAL","CENTER","OPPOSITE"
textSize:字号
bold:粗体
underline:下划线

generate_item_map(x, width, text, horizontalAlignment, textSize, bold, underline) {
    var itemMap = new Map();
    itemMap["x"] = "" + x;
    itemMap["width"] = "" + width;
    itemMap["text"] = "" + text;
    itemMap["horizontalAlignment"] = "" + horizontalAlignment;
    itemMap["textSize"] = "" + textSize;
    itemMap["bold"] = "" + bold;
    itemMap["underline"] = "" + underline;
    return itemMap;
},
test_print_multilingual() {
    this.open_port_if_not_opened();
    if (!SSPrint.Port_IsOpened(handle))
        return;

    //打印标题
    if (1) {
        var itemMapList = new Array();
        //标题只有一列,可以占满整个宽度,居中打印。
        itemMapList.push(this.generate_item_map(0,384,"多语言测试单据","CENTER",36,true,true));
        //按照水平线性布局打印文字
        //参数分别是:
        //  布局宽度(必须大于0)
        //  布局高度(可以等于0表示自动适应)
        //  垂直对齐(多列内容高度不一的时候有用)
        //  内容列表(列表中的每个内容,都有位置,宽度,水平对齐,等属性)
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);
    }

    //打印第一部分内容,主要演示水平线性布局坐标和对齐的用法。
    if (1) {
        var itemMapList;

        //每一条内容,都有一个宽度,和水平对齐。内容小于宽度的时候,就会按照指定对齐方式排版。
        //多条内容高度不一样的时候,垂直对齐就会生效。

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"品名","NORMAL",28,true,false));
        itemMapList.push(this.generate_item_map(200,100,"重量","CENTER",28,true,false));
        itemMapList.push(this.generate_item_map(300,84,"金额","OPPOSITE",28,true,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"虾子","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"1.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"60元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"超级帝王蟹","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"2.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"2600元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"非常好吃的大龙虾","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"3.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"1000元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"超极品美味超级大大大龙虾","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"3000.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"123456789元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"超极品美味超级大大大帝王蟹","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"30.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"1289元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 1, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"超极品美味超级大大大面包蟹","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"30.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"1289元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 2, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,200,"超极品美味超级大大大面包蟹","NORMAL",24,false,false));
        itemMapList.push(this.generate_item_map(200,100,"30.35kg","CENTER",24,false,false));
        itemMapList.push(this.generate_item_map(300,84,"1289元","OPPOSITE",24,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 100, 2, itemMapList);

    }

    //打印第二部分内容,主要演示多语言。
    if (1) {
        var itemMapList;

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,384,"人が心に抱き、信じられることは、すべて実現できる。","",28,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,384,"넌 찾아낼 거야 네 안에 있는","",28,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,384,"有一種思淰嘂嬡你","",28,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,384,"كان فى نيتى ان أتعرف عليكم منذ زمان ","",28,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,384,"อ่านสามวิธีหนึ่งคืออ่านแต่ไม่เข้าใจอ่านอีกทั้งยังเข้าใจและหนึ่งในหนังสือที่อ่านและเข้าใจในสิ่งที่พวกเขาไม่ได้","",28,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

        itemMapList = new Array();
        itemMapList.push(this.generate_item_map(0,384,"អ្នកចេះនិយាយភាសាខ្មែរទេ","",28,false,false));
        SSPrint.ESC_PrintTextImageUsingHorizontalLinearLayout(handle, 384, 0, 0, itemMapList);

    }

    SSPrint.ESC_PrintAndFeedPaperMultipleLines(handle, 6);
}

ESC_PrintBarcode

boolean ESC_PrintBarcode(long handle, String barcodeData, int barcodeType, int barcodeModuleWidth, int barcodeHeight, int barcodeHRITextFont, int barcodeHRITextPosition)

打印条码。不同类型条码可编码的字符和长度都不一样,条码数据需要符合条码要求。
handle:端口句柄
barcodeData 条码内容
barcodeType 条码类型,范围65-73(如用十六进制表示是:0x41-0x49)
barcodeModuleWidth 条码模块宽度,范围2-6,默认是3。
barcodeHeight 条码模块高度,范围1-255,默认162。
barcodeHRITextFont 条码可读字符字体,0:FontA, 1:FontB, 2:FontC
barcodeHRITextPosition 条码可读字符打印位置,0:不打印,1:打印在条码上方,2:打印在条码下方,3:打印在条码上方和下方。

//UPCA:65   有效字符11个,第12个字符是校验,自动生成。
SSPrint.ESC_PrintBarcode(handle, "12345678901", 65, 2, 40, 0, 2);
//UPCE:66   有效字符6个,第7个字符是校验,自动生成。
SSPrint.ESC_PrintBarcode(handle, "123456", 66, 2, 40, 0, 2);
//EAN13:67  有效字符12个,第13个字符是校验,自动生成。
SSPrint.ESC_PrintBarcode(handle, "123456789012", 67, 2, 40, 0, 2);
//EAN8:68   有效字符7个,第8个字符是校验,自动生成。
SSPrint.ESC_PrintBarcode(handle, "1234567", 68, 2, 40, 0, 2);
//CODE39:69 
SSPrint.ESC_PrintBarcode(handle, "123456", 69, 2, 40, 0, 2);
//ITF:70    偶数个字符
SSPrint.ESC_PrintBarcode(handle, "123456", 70, 2, 40, 0, 2);
//CODABAR:71
SSPrint.ESC_PrintBarcode(handle, "A123456A", 71, 2, 40, 0, 2);
//CODE93:72
SSPrint.ESC_PrintBarcode(handle, "123456", 72, 2, 40, 0, 2);
//CODE128:73 一般以"{B"开头

ESC_PrintQRCode

boolean ESC_PrintQRCode(long handle, String qrcodeData, int qrcodeModuleSize, int qrcodeErrorCorrectionLevel)

打印二维码
handle:端口句柄
qrcodeData 二维码内容
qrcodeModuleSize 二维码模块宽度,1-16
qrcodeErrorCorrectionLevel 二维码纠错等级 48:L 49:M 50:Q 51:H

//打印二维码 单元宽度1-16 纠错等级48:L 49:M 50:Q 51:H
SSPrint.ESC_PrintQRCode(handle, "hello world! 你好 世界!", 8, 48);

ESC_PrintImage

boolean ESC_PrintImage(long handle, String imagePathName, int mode)

打印图像
handle:端口句柄
imagePathName: 图像文件路径
mode: 打印模式 0:原尺寸打印 1:倍宽打印 2:倍高打印 3:倍宽倍高打印 大于等于8时:按照指定宽度打印

//打印模式 0:原尺寸打印 1:倍宽打印 2:倍高打印 3:倍宽倍高打印 大于等于8时:按照指定宽度打印
//SSPrint.ESC_PrintImage(handle, res.tempFilePaths[0], 0);
//SSPrint.ESC_PrintImage(handle, res.tempFilePaths[0], 1);
//SSPrint.ESC_PrintImage(handle, res.tempFilePaths[0], 2);
//SSPrint.ESC_PrintImage(handle, res.tempFilePaths[0], 3);
SSPrint.ESC_PrintImage(handle, res.tempFilePaths[0], 384);

ESC_PrintAndFeedPaperOneLine

boolean ESC_PrintAndFeedPaperOneLine(long handle)

打印并进纸一行
handle:端口句柄

ESC_PrintAndFeedPaperMultipleLines

boolean ESC_PrintAndFeedPaperMultipleLines(long handle, int n)

打印并进纸多行
handle:端口句柄

ESC_PrintAndFeedPaperMultipleDots

boolean ESC_PrintAndFeedPaperMultipleDots(long handle, int n)

打印并进纸多点
handle:端口句柄

ESC_FeedsPaperToCuttingPositionAndFullCut

boolean ESC_FeedsPaperToCuttingPositionAndFullCut(long handle)

走纸到切纸位置并全切
handle:端口句柄

ESC_FeedsPaperToCuttingPositionAndPartialCut

boolean ESC_FeedsPaperToCuttingPositionAndPartialCut(long handle)

走纸到切纸位置并半切
handle:端口句柄

ESC_KickOutDrawer

boolean ESC_KickOutDrawer(long handle)

打开钱箱
handle:端口句柄

ESC_InitializePrinter

boolean ESC_InitializePrinter(long handle)

初始化打印机
handle:端口句柄

ESC_SelectJustification

boolean ESC_SelectJustification(long handle, int n)

选择对齐方式
handle:端口句柄
n:对齐方式,对之后的文本、条码、二维码、图片都有效。0左对齐,1中对齐,2右对齐。

//对齐方式,对之后的文本、条码、二维码、图片都有效。0左对齐,1中对齐,2右对齐。
SSPrint.ESC_SelectJustification(handle, 0);
SSPrint.ESC_PrintText(handle, "Left\n", encoding, 0, 0, 0, 0);
SSPrint.ESC_SelectJustification(handle, 1);
SSPrint.ESC_PrintText(handle, "Center\n", encoding, 0, 0, 0, 0);
SSPrint.ESC_SelectJustification(handle, 2);
SSPrint.ESC_PrintText(handle, "Right\n", encoding, 0, 0, 0, 0);
SSPrint.ESC_SelectJustification(handle, 0);
SSPrint.ESC_PrintText(handle, "Left\n", encoding, 0, 0, 0, 0);

ESC_SetMotionUnit

boolean ESC_SetMotionUnit(long handle, int x, int y)

设置横向和纵向移动单位
handle:端口句柄
x:横向移动单位
y:纵向移动单位

ESC_SetPrintAreaLeftMargin

boolean ESC_SetPrintAreaLeftMargin(long handle, int n)

设置打印区域左边距
handle:端口句柄
n:左边距

//设置打印区域
SSPrint.ESC_SetPrintAreaLeftMargin(handle, 24);
SSPrint.ESC_SetPrintAreaWidth(handle, 300);
SSPrint.ESC_PrintText(handle, "12345678901234567890123456789012\n", encoding, 0, 0, 0, 0);
//恢复设置
SSPrint.ESC_InitializePrinter(handle);

ESC_SetPrintAreaWidth

boolean ESC_SetPrintAreaWidth(long handle, int n)

设置打印区域宽度
handle:端口句柄
n:打印区域宽度

//设置打印区域
SSPrint.ESC_SetPrintAreaLeftMargin(handle, 24);
SSPrint.ESC_SetPrintAreaWidth(handle, 300);
SSPrint.ESC_PrintText(handle, "12345678901234567890123456789012\n", encoding, 0, 0, 0, 0);
//恢复设置
SSPrint.ESC_InitializePrinter(handle);

ESC_SetHorizontalAbsolutePrintPosition

boolean ESC_SetHorizontalAbsolutePrintPosition(long handle, int n)

设置横向打印位置
handle:端口句柄
n:绝对打印位置

//文本列表
SSPrint.ESC_PrintText(handle, "--------------------------------\n", encoding, 0, 0, 0, 0);
SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 0);
SSPrint.ESC_PrintText(handle, "T0", encoding, 0, 0, 0, 0);
SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 60);
SSPrint.ESC_PrintText(handle, "T1", encoding, 0, 0, 0, 0);
SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 120);
SSPrint.ESC_PrintText(handle, "T2", encoding, 0, 0, 0, 0);
SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 180);
SSPrint.ESC_PrintText(handle, "T3", encoding, 0, 0, 0, 0);
SSPrint.ESC_PrintAndFeedPaperOneLine(handle);
SSPrint.ESC_PrintText(handle, "================================\n", encoding, 0, 0, 0, 0);
SSPrint.ESC_PrintAndFeedPaperMultipleDots(handle, 10);
for (let i = 0; i < 5; i++) {
    SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 0);
    SSPrint.ESC_PrintText(handle, "D"+i+"0", encoding, 0, 0, 0, 0);
    SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 60);
    SSPrint.ESC_PrintText(handle, "D"+i+"1", encoding, 0, 0, 0, 0);
    SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 120);
    SSPrint.ESC_PrintText(handle, "D"+i+"2", encoding, 0, 0, 0, 0);
    SSPrint.ESC_SetHorizontalAbsolutePrintPosition(handle, 180);
    SSPrint.ESC_PrintText(handle, "D"+i+"3", encoding, 0, 0, 0, 0);
    SSPrint.ESC_PrintAndFeedPaperOneLine(handle);
}
SSPrint.ESC_PrintText(handle, "================================\n", encoding, 0, 0, 0, 0);
SSPrint.ESC_PrintAndFeedPaperMultipleLines(handle, 2);
SSPrint.ESC_PrintText(handle, "================================\n", encoding, 0, 0, 0, 0);

ESC_SetHorizontalRelativePrintPosition

boolean ESC_SetHorizontalRelativePrintPosition(long handle, int n)

设置水平相对位置
handle:端口句柄
n:相对打印位置

//水平相对位置
SSPrint.ESC_PrintText(handle, "A00", encoding, 0, 0, 0, 0);
SSPrint.ESC_SetHorizontalRelativePrintPosition(handle, 12);
SSPrint.ESC_PrintText(handle, "B001", encoding, 0, 0, 0, 0);
SSPrint.ESC_SetHorizontalRelativePrintPosition(handle, 12);
SSPrint.ESC_PrintText(handle, "C0", encoding, 0, 0, 0, 0);
SSPrint.ESC_SetHorizontalRelativePrintPosition(handle, 12);
SSPrint.ESC_PrintText(handle, "D0", encoding, 0, 0, 0, 0);
SSPrint.ESC_PrintAndFeedPaperOneLine(handle);

ESC_SetLineHeight

boolean ESC_SetLineHeight(long handle, int n)

设置行高
handle:端口句柄
n:行高

隐私、权限声明

1. 本插件需要申请的系统权限列表:

蓝牙权限,用于连接蓝牙打印机 定位权限,用于搜索蓝牙打印机 网络权限,以便通过TCP连接打印机

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问