react-native-esc-pos-printer: Image directory problem for imageAsset()

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 on android/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.

printing.initialize().imageAsset('634020369600.png', 200);

This is the error that I am getting:

{
"nativeStackAndroid":[],
"userInfo":null,
"message":"1634020369600.png",
"code":"EUNSPECIFIED",
"line":2760,"
column":45,
"sourceURL":"http://localhost:8081/index.bundle?platform=android&dev=true&minify=false"
}

It will be very much helpful if anyone can solve what I am missing.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 36 (36 by maintainers)

Most upvoted comments

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.

@tr3v3r Thank you very much this is a very useful feature. I will check this out soon.

@kamal-hossain no final app size will be fine) we’ve already used it in production for iOS and Android

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

@kamal-hossain thanks! branch - imageBase64-method

@kamal-hossain yeap give me a couple of hours to test methods for base64. They’ve already done but not tested on real device