react-native-bluetooth-escpos-printer icon indicating copy to clipboard operation
react-native-bluetooth-escpos-printer copied to clipboard

remove white space between images in the printPic method ??

Open LeanPerez21 opened this issue 3 years ago • 3 comments

index

LeanPerez21 avatar Sep 24 '21 15:09 LeanPerez21

@LeanPerez21 can you please share you code i am stuck I got blank when I print image

await BluetoothEscposPrinter.printPic(base64JpgLogo, { width: 40, left: 0, });

feras-merwas avatar Nov 11 '21 08:11 feras-merwas

same issue please help

zhietan avatar Dec 04 '21 06:12 zhietan

android/src/main/java/cn/jystudio/bluetooth/escpos/RNBluetoothEscposPrinterModule.java

@ReactMethod
    public void printPic(String base64encodeStr, @Nullable  ReadableMap options) {
        int width = 0;
        int leftPadding = 0;
        if(options!=null){
            width = options.hasKey("width") ? options.getInt("width") : 0;
            leftPadding = options.hasKey("left")?options.getInt("left") : 0;
        }

        //cannot larger then devicesWith;
        if(width > deviceWidth || width == 0){
            width = deviceWidth;
        }

        byte[] bytes = Base64.decode(base64encodeStr, Base64.DEFAULT);
        Bitmap mBitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
        int nMode = 0;
        if (mBitmap != null) {
            /**
             * Parameters:
             * mBitmap  要打印的图片
             * nWidth   打印宽度(58和80)
             * nMode    打印模式
             * Returns: byte[]
             */
            byte[] data = PrintPicture.POS_PrintBMP(mBitmap, width, nMode, leftPadding);
            //  SendDataByte(buffer);
            sendDataByte(Command.ESC_Init);
            sendDataByte(Command.LF);
            sendDataByte(data);
            remove this line // sendDataByte(PrinterCommand.POS_Set_PrtAndFeedPaper(30));
            remove this line // sendDataByte(PrinterCommand.POS_Set_Cut(1));
            remove this line // sendDataByte(PrinterCommand.POS_Set_PrtInit());
        }
    }

elemanjan avatar Oct 20 '22 12:10 elemanjan