januslo / react-native-sunmi-inner-printer

http://docs.sunmi.com/htmls/index.html?lang=zh##V1文档资源 根据商米V1文档开发的热敏打印
MIT License
74 stars 121 forks source link

Using setBold #36

Closed hewrin closed 5 years ago

hewrin commented 5 years ago

Is there a way to use setBold method?

I see it in the Java files, but not sure how to use it in Javascript.

Thank you very much

januslo commented 5 years ago

Seems you mean the command definition in ESCUtils.java like:

/**
     * 选择加粗模式
     * 
     * @return
     */
    public static byte[] boldOn() {
        byte[] result = new byte[3];
        result[0] = ESC;
        result[1] = 69;
        result[2] = 0xF;
        return result;
    }

    /**
     * 取消加粗模式
     * 
     * @return
     */
    public static byte[] boldOff() {
        byte[] result = new byte[3];
        result[0] = ESC;
        result[1] = 69;
        result[2] = 0;
        return result;
    }

Unfortunately, I have't exposed them to the module. How ever you can try to send these commands via sendRAWData(base64String) , like:

SunmiInnerPrinter.sendRAWData(base64.encode([0x10,69,0xF])); // not tested actually.  
hewrin commented 5 years ago

So I do something like

   await SunmiInnerPrinter.sendRAWData(base64.encode([0x10, 69, 0xF]))
   await SunmiInnerPrinter.printOriginalText("HELLO");

Is this correct?

januslo commented 5 years ago

yeah, should be something like that. But you need more tests to make things done i think.