-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
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
Image directory problem for imageAsset() #23
Comments
@kamal-hossain hello! Am I write that you are using an expo project? |
@tr3v3r thanks for your quick response. |
So as I understood you need to print a remote images? |
I am unsure how can I use the |
Yes I need to print a remote image, but I have found that this package doesn't support remote image print, thats why I am trying to download and print the image. |
@kamal-hossain I'm already working on the imageBase64 image method (which is also could help ). I'll let you know about the results ) |
Yes, imageBase64 can also help me for now. |
@kamal-hossain yeap give me a couple of hours to test methods for base64. |
@kamal-hossain I need your help. Everything you need to do is just run project from example folder and press on two buttons |
Sure thing, give me some times. I am on it. |
@kamal-hossain thanks! |
@kamal-hossain have you run it inside example folder? |
I don't think it connected with yarn ver. (btw mine is 1.22.11) |
Ok sure I am trying with npm. |
I have tried with cmd and bash. |
sorry I accidentally, closed the issue. |
Can you tell me what changes you have made for base64 printing in your current published? And I have tried with npm, it doesn't work. |
@kamal-hossain you can simply use the link to branch version directly in package.json of your project like "dependencies': {
...
"react-native-esc-pos-printer": "git://github.com/tr3v3r/react-native-esc-pos-printer.git#imageBase64-method"
...
}
And then just use
|
I have changed |
@kamal-hossain Understood. And also it would be nice if you could check that all needed updates included in you node_modules/react-native-esc-pos-printer lib. Check please if case PrintingCommands.COMMAND_ADD_IMAGE_BASE_64:
String uriString = params.getString(0);
final String pureBase64Encoded = uriString.substring(uriString.indexOf(",") + 1);
byte[] decodedString = Base64.decode(pureBase64Encoded, Base64.DEFAULT);
Bitmap bitmap = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
int inputWidth = params.getInt(1);
handlePrintImage(bitmap, inputWidth);
break;
Also could you please share the image you've tried to print? |
@kamal-hossain just found a real device - print image from base64 works as expected with the asset from this link |
Have you tried to play with the width? |
Yes I did! And it is working totally fine! I have printed the actual size. Thanks alot! So, now I have to convert all the images to base64, do you know any react native package for converting images to base64? Otherwise I will have to convert them from backend and get them, which is a lengthy process. |
actually, rn-fetch-blob for example allows you to download an image and save it as base64. I suppose the manager you are using also could provide such functionality. Anyway I'll try tomorrow investigate a bit about printing from remote url |
Thanks @tr3v3r this will be very much helpful, and I think this is a very important feature.
|
@kamal-hossain Thanks to you too for the help! docs also updated |
Unpacked Size is 150 MB in npm. Will the effect the real app size at play store? |
@kamal-hossain no final app size will be fine) we’ve already used it in production for iOS and Android |
@tr3v3r |
@kamal-hossain hi! printing.initialize()
.image(require('./store.png'), {
width: 75,
halftone: 'EPOS2_HALFTONE_THRESHOLD',
})
.image({ uri: base64Image }, { width: 75 })
.image(
{
uri:
'https://raw.githubusercontent.com/tr3v3r/react-native-esc-pos-printer/main/ios/store.png',
},
{ width: 75 }
)
.cut()
.send(); |
@tr3v3r |
I'm trying to print image from my android device.
In this doc it is instructed to store image on this path
android/app/src/main/assets
. So I have used expo MediaLibrary for download and store the image onandroid/app/src/main/assets
path.My actual image path is
file:///storage/emulated/0/android/app/src/main/assets/1634020369600.png
And I am calling the the print function like that.
This is the error that I am getting:
It will be very much helpful if anyone can solve what I am missing.
The text was updated successfully, but these errors were encountered: