Printooth library, label feed control issue

走远了吗. 提交于 2021-02-11 13:53:57

问题


I am new in Android development. The following bloc is part of my APP's code, it does a simple job of select two columns of information from a local sqlite database's table, filter it by a scanned barcode and print the information retrieved plus the current date.

My issue is the label feed control. Printer only execute Android APP's command when in ESC/POS mode, and doesn't stop the label paper in the right position for the next label to be printed. If anyone have ever made something similar which also controls thermal printer's paper feed by software, please share your experience.

Make and model of the printer I am using: Toshiba B-EP4DL

private void printText() {
    ArrayList<Printable> printables = new ArrayList<>();
    printables.add(new RawPrintable.Builder(new byte[]{27, 100, 4}).build());

    myDb.setBarcodcheck(String.valueOf(barcodefield.getText()));
    Cursor res = myDb.getAllData();
    if (res.getCount() == 0) {
        showMessage("Error", "Nothing Found");
        return;
    }
    StringBuffer buffer = new StringBuffer();
    while (res.moveToNext()) {
        buffer.append("LOCATION: "+ res.getString(0)+"\n");
        buffer.append("APPROVED: "+ res.getString(1)+"\n");
        buffer.append("DATE: "+date+"\n");
    }

    printables.add(new TextPrintable.Builder()
            .setText(buffer.toString())
            .setCharacterCode(DefaultPrinter.Companion.getCHARCODE_PC1252())
            .setLineSpacing(DefaultPrinter.Companion.getLINE_SPACING_60())
            .setEmphasizedMode(DefaultPrinter.Companion.getEMPHASIZED_MODE_BOLD())
            .setFontSize(DefaultPrinter.Companion.getFONT_SIZE_LARGE())
            //.setNewLinesAfter(1)
            .build());

    Printooth.INSTANCE.printer().print(printables);
}

来源:https://stackoverflow.com/questions/60114412/printooth-library-label-feed-control-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!