CesarBalzer / Cordova-Plugin-BTPrinter

A cordova plugin for bluetooth printer for android platform
Apache License 2.0
80 stars 63 forks source link

printBase64 reduces image size #44

Closed jefelon closed 1 year ago

jefelon commented 3 years ago

printBase64 reduces the image size and there is no way to send something to make something bigger. The original size is adequate, but this plugin resizes it.

aldesha989 commented 2 years ago

?

mohamedazher commented 2 years ago

The plugin resizes the image before printing. To get the best result, you can the following.

Set the alignment to center while sending the base64 for print.

And you can try opening BluetoothPrinter.java file (not the one in the plugins folder, but the one inside android/src folder) and find the method printBase64, find the resizeImage function which has 3 parameters, first is the image itself, second is the height, third one is the width.

The default is

 bitmap = decodedBitmap;
 int mWidth = bitmap.getWidth();
 int mHeight = bitmap.getHeight();

bitmap = resizeImage(bitmap, 48*8, mHeight);

You can try changing 48*8 to get the size you want, it still does not print full width, but better than the current size. For me setting size 560 worked the best with center align