Closed panhavey closed 2 years ago
I didn't see you list it down. Do I need to use it as NativeModule?
I didn't see you list it down. Do I need to use it as NativeModule?
I don't have to. I forgot to list it
I didn't see you list it down. Do I need to use it as NativeModule?
I don't have to. I forgot to list it
It shows error : Property 'printBitmap'Custom does not exist on type 'SunmiPrinterType'.
I didn't see you list it down. Do I need to use it as NativeModule?
I don't have to. I forgot to list it
It shows error : Property 'printBitmap'Custom does not exist on type 'SunmiPrinterType'.
hold on
I didn't see you list it down. Do I need to use it as NativeModule?
I don't have to. I forgot to list it
It shows error : Property 'printBitmap'Custom does not exist on type 'SunmiPrinterType'.
hold on
If you working on it please also check SunmiScan, it doesn't return result.
I didn't see you list it down. Do I need to use it as NativeModule?
I don't have to. I forgot to list it
It shows error : Property 'printBitmap'Custom does not exist on type 'SunmiPrinterType'.
hold on
If you working on it please also check SunmiScan, it doesn't return result.
ok
Ok, you can use it now
Ok, you can use it now
It got error : 'Got unknown argument class: Bitmap'
+1 also getting 'Got unknown argument class: Bitmap'
+1 also getting 'Got unknown argument class: Bitmap'
Sorry, I am currently working from home and cannot debug.
@mikgross printBitmap
,There is one more, you can try
I tried
import cheekin from './../assets/printerImages/cheekin.bmp';
var printImage = Image.resolveAssetSource(cheekin).uri;
SunmiPrinter.printBitmap(printImage)
&&
import cheekin from './../assets/printerImages/cheekin.bmp';
var printImage = Image.resolveAssetSource(cheekin).uri;
SunmiPrinter.printBitmapCustom(printImage)
None work, any idea what I should do? Can you include a working example in the example app?
Unfortunately the printing for images is not working. I have additionally tried to modify your package with a base64 string implementation then decoded as bitmap, it does not print. Do you have a working example?
Le mar. 5 avr. 2022 à 06:39, 夜雨 @.***> a écrit :
@mikgross https://github.com/mikgross printBitmap ,There is one more, you can try
— Reply to this email directly, view it on GitHub https://github.com/Surile/react-native-sunmi-printer/issues/1#issuecomment-1088260998, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIWEOLKHUY35KP6A3MGEH43VDO7XRANCNFSM5IFZFBDA . You are receiving this because you were mentioned.Message ID: @.***>
@mikgross There may be a problem with the api
I have changed the Bitmap format to base64 string in the main input. and changed the handler as such:
public void printBitmap(String encodedString, Int pixelWidth) throws RemoteException {
final String pureBase64Encoded = encodedString.substring(encodedString.indexOf(",") + 1);
final byte[] decodedBytes = Base64.decode(pureBase64Encoded, Base64.DEFAULT);
Bitmap decodedBitmap = BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length);
int w = decodedBitmap.getWidth();
Integer h = decodedBitmap.getHeight();
Bitmap scaledImage = Bitmap.createScaledBitmap(decodedBitmap, pixelWidth, (pixelWidth / w) * h, false);
printerService.printBitmap(scaledImage, innerResultCallback);
}
Works fine. Do you want me to do a pull request?
I have changed the Bitmap format to base64 string in the main input. and changed the handler as such:
public void printBitmap(String encodedString, Int pixelWidth) throws RemoteException { final String pureBase64Encoded = encodedString.substring(encodedString.indexOf(",") + 1); final byte[] decodedBytes = Base64.decode(pureBase64Encoded, Base64.DEFAULT); Bitmap decodedBitmap = BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length); int w = decodedBitmap.getWidth(); Integer h = decodedBitmap.getHeight(); Bitmap scaledImage = Bitmap.createScaledBitmap(decodedBitmap, pixelWidth, (pixelWidth / w) * h, false); printerService.printBitmap(scaledImage, innerResultCallback); }
Works fine. Do you want me to do a pull request?
Hi, @mikgross . I installed this package today and when I'm trying to use printBitmap I get an error: "width and height must be > 0"
Did you have the same issue? If yes how did you resolve it. Thanks.
Hi @Surile, any updates? I have the same issue.
It has been updated
It has been updated
@Surile , It has been updated by @mikgross last time. But his fix doesn't work for me. If I try to pass to the printBitmap() method the base64 encoded image and width for it, I'll receive an error: "width and height must be > 0"
I can't pass three params - image, height and width. Typescript returned an error that method accept only two params. With two params the as issue as @SVPetrenko.
@orlenko-dmitry @SVPetrenko Whether to take off data:image/png;base64
@Surile , sorry, what do you mean?
Whether to delete data:image/png;base64
same issue "width and height must be > 0"
@Surile same issue "width and height must be > 0"
while it SunmiPrinter.printBitmap() accepts only two parameters : encodedString and pixelWidth.
What is the solution?? Help will be much appreciated
@Surile @ngondat97 @orlenko-dmitry @SVPetrenko I found the solution for "widht and height must be > 0" issue.
The image that we are trying to print from the printer has greater width than the receipt of the printer. So, image should be within the 384 width or maybe less than 384. Pass 384 as a pixelwidth of printbitmap method and provide the base64 string of image with the width less than 384 if you are using 58mm paper printer.
I hope this will help .
I have changed the Bitmap format to base64 string in the main input. and changed the handler as such:
public void printBitmap(String encodedString, Int pixelWidth) throws RemoteException { final String pureBase64Encoded = encodedString.substring(encodedString.indexOf(",") + 1); final byte[] decodedBytes = Base64.decode(pureBase64Encoded, Base64.DEFAULT); Bitmap decodedBitmap = BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length); int w = decodedBitmap.getWidth(); Integer h = decodedBitmap.getHeight(); Bitmap scaledImage = Bitmap.createScaledBitmap(decodedBitmap, pixelWidth, (pixelWidth / w) * h, false); printerService.printBitmap(scaledImage, innerResultCallback); }
Works fine. Do you want me to do a pull request?
Hi, @mikgross . I installed this package today and when I'm trying to use printBitmap I get an error: "width and height must be > 0"
Did you have the same issue? If yes how did you resolve it. Thanks.
Hey man, sory for my late reply. Maybe you already got it working.
I belive your issue is coming from having a wrongly encoded image. Mine is correctly encoded and throws back the width and hight accoridng to what should be.
Didi you resolve your issue?
Hi, @mikgross. No, it is still not working for me. Currently, I'm using a temporary solution.
Perhaps, you are right. How is it possible to check? Or could you probably tell me which way you encoded an image?
Any solution ? I have same error.. @Surile, @mikgross same issue "width and height must be > 0"
Any solution ? I have same error.. @Surile, @mikgross same issue "width and height must be > 0"
Can you share the code of the method that you are using ? And what is your printer paper width specification?
Any solution ? I have same error.. @Surile, @mikgross same issue "width and height must be > 0"
Can you share the code of the method that you are using ? And what is your printer paper width specification?
@Rehankhalil462 paper width is 58mm then
I have tried like this:
RNFS.readFileAssets('profile.bmp', 'base64') .then(content => { console.log('printImage: ' + content); SunmiPrinter.printBitmap(content, 34); })
or
Using direct string base64 and removing data:image/bmp;base64 but always i have same result..
Do you have any base64 string that this work ?
@javi2491 try SunmiPrinter.printBitmap(content, 384)
But keep this in mind that the width of the picture that you are trying to print must be less than 384 pixels.
@javi2491 try
SunmiPrinter.printBitmap(content, 384)
But keep this in mind that the width of the picture that you are trying to print must be less than 384 pixels.
Thanks @Rehankhalil462 , its work for me.
@javi2491 You're welcome. I'm glad to hear this.