We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
[email protected]
Here is the diff that solved my problem:
diff --git a/node_modules/thermal-printer-cordova-plugin/src/android/ThermalPrinterCordovaPlugin.java b/node_modules/thermal-printer-cordova-plugin/src/android/ThermalPrinterCordovaPlugin.java index b2aa637..9dd25bb 100644 --- a/node_modules/thermal-printer-cordova-plugin/src/android/ThermalPrinterCordovaPlugin.java +++ b/node_modules/thermal-printer-cordova-plugin/src/android/ThermalPrinterCordovaPlugin.java @@ -80,9 +80,26 @@ public class ThermalPrinterCordovaPlugin extends CordovaPlugin { private void bytesToHexadecimalString(CallbackContext callbackContext, JSONObject data) throws JSONException { EscPosPrinter printer = this.getPrinter(callbackContext, data); try { - byte[] bytes = (byte[]) data.get("bytes"); + byte[] bytes = (byte[]) data.get("bytes"); Bitmap decodedByte = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); - callbackContext.success(PrinterTextParserImg.bitmapToHexadecimalString(printer, decodedByte)); + int targetWidth = 383; + //(int) (201 * 5.6 / 2); + int targetHeight = (int) ((201 * 5.6 / 2.54) * 2); + //Math.round(decodedByte.getHeight() * targetWidth / decodedByte.getWidth()); + + //(int) ((201 * 5.6 / 2.54) * 3) + Bitmap resizedBitmap = Bitmap.createScaledBitmap(decodedByte, targetWidth ,targetHeight , true); + decodedByte.recycle(); + + int width = resizedBitmap.getWidth(), height = resizedBitmap.getHeight(); + StringBuilder textToPrint = new StringBuilder(); + for(int y = 0; y < height; y += 256) { + Bitmap bitmap = Bitmap.createBitmap(resizedBitmap, 0, y, width, (y + 256 >= height) ? height - y : 256); + textToPrint.append("[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, bitmap) + "</img>\n"); + } + + textToPrint.append("[C]Printed!!!\n"); + callbackContext.success(String.valueOf(textToPrint)); } catch (Exception e) { callbackContext.error(new JSONObject(new HashMap<String, Object>() {{ put("error", e.getMessage());
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
[email protected]
for the project I'm working on.Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: