react-native-bluetooth-escpos-printer
react-native-bluetooth-escpos-printer copied to clipboard
remove white space between images in the printPic method ??
@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, });
same issue please help
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());
}
}