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

BLEPrinter.printImage does not work #6

Closed
chukiatt opened this issue Dec 6, 2021 · 27 comments · Fixed by #10
Closed

BLEPrinter.printImage does not work #6

chukiatt opened this issue Dec 6, 2021 · 27 comments · Fixed by #10
Labels
enhancement New feature or request

Comments

@chukiatt
Copy link

chukiatt commented Dec 6, 2021

i try to print image but it does not print anything

BLEPrinter.printImage("https://sportshub.cbsistatic.com/i/2021/04/09/9df74632-fde2-421e-bc6f-d4bf631bf8e5/one-piece-trafalgar-law-wano-anime-1246430.jpg");

actually i need to print image from dataUri

BLEPrinter.printImage("uri:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3/OAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANCSURBVEiJtZZPbBtFFMZ/M7ubXdtdb1xSFyeilBapySVU8h8OoFaooFSqiihIVIpQBKci6KEg9Q6H9kovIHoCIVQJJCKE1ENFjnAgcaSGC6rEnxBwA04Tx43t2FnvDAfjkNibxgHxnWb2e/u992bee7tCa00YFsffekFY+nUzFtjW0LrvjRXrCDIAaPLlW0nHL0SsZtVoaF98mLrx3pdhOqLtYPHChahZcYYO7KvPFxvRl5XPp1sN3adWiD1ZAqD6XYK1b/dvE5IWryTt2udLFedwc1+9kLp+vbbpoDh+6TklxBeAi9TL0taeWpdmZzQDry0AcO+jQ12RyohqqoYoo8RDwJrU+qXkjWtfi8Xxt58BdQuwQs9qC/afLwCw8tnQbqYAPsgxE1S6F3EAIXux2oQFKm0ihMsOF71dHYx+f3NND68ghCu1YIoePPQN1pGRABkJ6Bus96CutRZMydTl+TvuiRW1m3n0eDl0vRPcEysqdXn+jsQPsrHMquGeXEaY4Yk4wxWcY5V/9scqOMOVUFthatyTy8QyqwZ+kDURKoMWxNKr2EeqVKcTNOajqKoBgOE28U4tdQl5p5bwCw7BWquaZSzAPlwjlithJtp3pTImSqQRrb2Z8PHGigD4RZuNX6JYj6wj7O4TFLbCO/Mn/m8R+h6rYSUb3ekokRY6f/YukArN979jcW+V/S8g0eT/N3VN3kTqWbQ428m9/8k0P/1aIhF36PccEl6EhOcAUCrXKZXXWS3XKd2vc/TRBG9O5ELC17MmWubD2nKhUKZa26Ba2+D3P+4/MNCFwg59oWVeYhkzgN/JDR8deKBoD7Y+ljEjGZ0sosXVTvbc6RHirr2reNy1OXd6pJsQ+gqjk8VWFYmHrwBzW/n+uMPFiRwHB2I7ih8ciHFxIkd/3Omk5tCDV1t+2nNu5sxxpDFNx+huNhVT3/zMDz8usXC3ddaHBj1GHj/As08fwTS7Kt1HBTmyN29vdwAw+/wbwLVOJ3uAD1wi/dUH7Qei66PfyuRj4Ik9is+hglfbkbfR3cnZm7chlUWLdwmprtCohX4HUtlOcQjLYCu+fzGJH2QRKvP3UNz8bWk1qMxjGTOMThZ3kvgLI5AzFfo379UAAAAASUVORK5CYII=")

could you suggest the right way to solve that

thank you very much

@thiendangit
Copy link
Owner

@chukiatt What platform are you having problems?

@chukiatt
Copy link
Author

chukiatt commented Dec 6, 2021 via email

@thiendangit
Copy link
Owner

@chukiatt I don't have a bluetooth printer at the moment so I can't develop and test this feature yet! but I'll try to find a way to guide you through its development and testing.!

@thiendangit
Copy link
Owner

@chukiatt if you only develop print feature for android and bluetooth you can try using this library: https://www.npmjs.com/package/react-native-thermal-printer

@chukiatt
Copy link
Author

chukiatt commented Dec 6, 2021 via email

@thiendangit
Copy link
Owner

@chukiatt I'll try to develop this feature! Can you help me test it because i don't have bluetooth printer?

@chukiatt
Copy link
Author

chukiatt commented Dec 6, 2021 via email

@chukiatt
Copy link
Author

chukiatt commented Dec 6, 2021

very welcome

thank you very much

@thiendangit
Copy link
Owner

thiendangit commented Dec 6, 2021

@chukiatt please try again!

@thiendangit thiendangit added the enhancement New feature or request label Dec 6, 2021
@chukiatt
Copy link
Author

chukiatt commented Dec 7, 2021

after update to "react-native-thermal-receipt-printer-image-qr": "^0.1.3",
i got this error

TypeError: RNBLEPrinter.printImageData is not a function

@thiendangit
Copy link
Owner

@chukiatt i added it in v0.1.3 for android version already! try to remove yarn.lock and react-native-thermal-receipt-printer-image-qr in your node_modules and try again!

@chukiatt
Copy link
Author

chukiatt commented Dec 7, 2021

@thiendangit i will try again and response to inform you

@chukiatt
Copy link
Author

chukiatt commented Dec 7, 2021

@thiendangit i make sure by created a new react native app for test and then install only your library

npx react-native init testProject
npm install react-native-thermal-receipt-printer-image-qr
react-native run-android --deviceId=SWTOAIKNM78TCYSW

app build success. but printImage is still error

TypeError: RNBLEPrinter.printImageData is not a function. (In 'RNBLEPrinter.printImageData(imgUrl, function (error) {
return console.warn(error);
})', 'RNBLEPrinter.printImageData' is undefined)

@thiendangit
Copy link
Owner

@chukiatt Ahhh sr. i see this error! I’ll fix it in the morning.

@chukiatt
Copy link
Author

chukiatt commented Dec 8, 2021

Thank you very much

@thiendangit
Copy link
Owner

@chukiatt i fixed in v0.1.4

@chukiatt
Copy link
Author

chukiatt commented Dec 8, 2021

@thiendangit It's work. I am very glad

i not sure it's support both Android and iOS ?

Thank you very much

@thiendangit
Copy link
Owner

thiendangit commented Dec 8, 2021

@chukiatt Does Android work? if you want to print pictures with bluetooth in ios or with base64 uri, I can help you!

@chukiatt
Copy link
Author

chukiatt commented Dec 8, 2021

@thiendangit Yes, i want to print in both platform include base64 uri

my goal is draw everything to image (text and picture) and export to base64 toDataURL() to print. this idea is pretty good for almost printer can print without a problem (not only epson and star)

thanks for your help

@thiendangit
Copy link
Owner

thiendangit commented Dec 8, 2021

@chukiatt ok i'll try it tonight 😁

@thiendangit
Copy link
Owner

thiendangit commented Dec 9, 2021

@chukiatt please try :

  • Add this line to package.json :

react-native-thermal-receipt-printer-image-qr : "https://github.com/thiendangit/react-native-thermal-receipt-printer-image-qr.git"

  • Using function printQrCode to print image with base64 in android and ios!
  • Using function printImage to print image with url in android and ios!

@chukiatt
Copy link
Author

@thiendangit

Thank you for your help. Your library will be an important part of the build POS project. of Thailand

Thank you very much

@thiendangit
Copy link
Owner

thiendangit commented Dec 10, 2021

@chukiatt is print BLUETOOTH working? if it working, i'll release new version!

@chukiatt
Copy link
Author

Yes, now i tested only bluetooth, It's work well.

@thiendangit
Copy link
Owner

@chukiatt wow! many tks 🎉.
Both android and ios are ok? ? give me star if you like my repos 😚 😚

@thecodecafe
Copy link
Contributor

thecodecafe commented Dec 10, 2021

Hi @thiendangit, this is a great library, I just tried BLEPrinter.printQrCode(base64EncodedImage) and got an error saying printQrCode is not a function in RNBLEPrinter.printQrCode(qrCodeBas64, function(error) {return console.warn(error);}) RNBLEPrinter.printQrCode is undefined.
I've given a star! 😊

[Edit]
This is happening on Android, this is the only platform I can test for right now.
The problem was that in RNBLEPrinter the printQrCode method does not have @ReactMethod so it's not exported in NativeModules.

@thiendangit
Copy link
Owner

@thecodecafe many tks! I was careless

@thiendangit thiendangit linked a pull request Dec 12, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants