Skip to content
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

Print local image #45

Closed
rohitatcoffee opened this issue Apr 8, 2022 · 8 comments
Closed

Print local image #45

rohitatcoffee opened this issue Apr 8, 2022 · 8 comments
Labels
help wanted Extra attention is needed

Comments

@rohitatcoffee
Copy link

Is there any way to print local images? I tried converting the image to base64 but the printer is printing garbage data. But I passed image link then it get printed.

@thiendangit
Copy link
Owner

@rohitatcoffee please try to using this function : printImageBase64

@rohitatcoffee
Copy link
Author

rohitatcoffee commented Apr 8, 2022

@rohitatcoffee please try to using this function : printImageBase64

Yes, I tried that one too. printImageBase64 only takes base64 data not local image URI.
I am using Everycom EC-58 58mm printer

@thiendangit
Copy link
Owner

you can using this lib to capture -> covert to base64-> print
https://github.com/gre/react-native-view-shot

@rohitatcoffee
Copy link
Author

rohitatcoffee commented Apr 8, 2022

I am doing the following things,

  1. Render data in Webview
  2. Capture screenshots using https://github.com/gre/react-native-view-shot
  3. Then convert screenshot to base64 using react-native-fs and print using Printer.printImageBase64(res, { beep: false, imageWidth:600});

But still getting messed up data.

[](https://i.ibb.co/hf3JKqg/20220407-183129.jpg)

@thiendangit
Copy link
Owner

maybe your base64 is wrong!
try this :

let qrProcessed = dataURL.replace(/(\r\n|\n|\r)/gm, "");

@thiendangit thiendangit added the help wanted Extra attention is needed label Apr 8, 2022
@rohitatcoffee
Copy link
Author

@thiendangit I am able to solve this issue, the issue was the width. I was passing images with the wrong dimensions.

@yaser-elbatal
Copy link

@thiendangit I am able to solve this issue, the issue was the width. I was passing images with the wrong dimensions.

what is the best dimensions?

@OhFarhan
Copy link

if you are printing in a small printer use image width less than 200 or 300 @rohitatcoffee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants