Open gayathri-17 opened 6 years ago
declare var sunmiInnerPrinter: any;
you need to use the "sunmiInnerPrinter" after ionViewDidLoad()
if you want to see the error on using the "sunmiInnerPrinter", you enclose your code inside the try - catch block.
try { if (JSON.stringify(sunmiInnerPrinter) !== "{}") { return; } // it is safe to use sunmiInnerPrinter here } catch(err) { console.log("error: "+ JSON.stringify(err)); }
- you need to declare the variables before any class declaration as follows:
declare var sunmiInnerPrinter: any;
- you need to use the "sunmiInnerPrinter" after ionViewDidLoad()
- if you want to see the error on using the "sunmiInnerPrinter", you enclose your code inside the try - catch block.
try { if (JSON.stringify(sunmiInnerPrinter) !== "{}") { return; } // it is safe to use sunmiInnerPrinter here } catch(err) { console.log("error: "+ JSON.stringify(err)); }
//// Hi sir , i did that, but i got same error , import { Component } from '@angular/core'; import { IonicPage, NavController, NavParams } from 'ionic-angular';
declare var sunmiInnerPrinter: any; @IonicPage() @Component({ selector: 'page-receipt', templateUrl: 'receipt.html', }) export class ReceiptPage {
constructor(public navCtrl: NavController, public navParams: NavParams) { this.print(); }
ionViewDidLoad() {
console.log('ionViewDidLoad ReceiptPage');
}
print(){
try {
if (JSON.stringify(sunmiInnerPrinter) !== "{}") {
return;
}
// it is safe to use sunmiInnerPrinter here
} catch(err) {
console.log("error: "+ JSON.stringify(err));
}
// (
- make sure you have the cordova-plugin-sunmi-inner-printer
- please do the ff: cd to your project dir and type "cordova plugin list"
ya i am having sir, cordova-plugin-device 2.0.2 "Device" cordova-plugin-inappbrowser 3.0.0 "InAppBrowser" cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 2.2.0 "cordova-plugin-ionic-webview" cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-statusbar 2.4.2 "StatusBar" cordova-plugin-whitelist 1.3.3 "Whitelist" cordova-sunmi-inner-printer 1.0.0 "SunmiInnerPrinter" phonegap-plugin-barcodescanner 8.0.0 "BarcodeScanner" is there i want to import in app.module.ts file
I remember I have the same problem, then I did modify this plugin. I will post the modify version asap
I remember I have the same problem, then I did modify this plugin. I will post the modify version asap
Tq sir, pls post asap
@gayu1712
1. cd PATH/TO/NEW/SUNMI/PRINTER git clone git@github.com@tmalbonph:cordova-plugin-sunmi-inner-printer.git
2. cd PATH/OF/YOUR/IONIC/PROJECT ionic cordova plugin rm cordova-plugin-sunmi-inner-printer
3. ionic cordova plugin add PATH/TO/NEW/SUNMI/PRINTER/cordova-plugin-sunmi-inner-printer --nofetch
4. cordova plugin list
cordova-plugin-compat 1.2.0 "Compat" cordova-plugin-console 1.1.0 "Console" cordova-plugin-device 1.1.7 "Device" cordova-plugin-inappbrowser 1.7.2 "InAppBrowser" cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview" cordova-plugin-native-spinner 1.1.3 "Native Spinner" cordova-plugin-splashscreen 4.1.0 "Splashscreen" cordova-plugin-statusbar 2.4.1 "StatusBar" cordova-plugin-sunmi-inner-printer 1.1.0 "SunmiInnerPrinter" cordova-plugin-whitelist 1.3.3 "Whitelist" es6-promise-plugin 4.2.2 "Promise" ionic-plugin-deeplinks 1.0.15 "Ionic Deeplink Plugin" ionic-plugin-keyboard 2.2.1 "Keyboard"
dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile "com.sunmi:sunmiui:latest.release" <------ ADD THIS // SUB-PROJECT DEPENDENCIES START debugCompile(project(path: "CordovaLib", configuration: "debug")) releaseCompile(project(path: "CordovaLib", configuration: "release")) // SUB-PROJECT DEPENDENCIES END }
@gayu1712
cd PATH/TO/NEW/SUNMI/PRINTER git clone git@github.com@tmalbonph:cordova-plugin-sunmi-inner-printer.git
cd PATH/OF/YOUR/IONIC/PROJECT ionic cordova plugin rm cordova-plugin-sunmi-inner-printer
ionic cordova plugin add PATH/TO/NEW/SUNMI/PRINTER/cordova-plugin-sunmi-inner-printer --nofetch
cordova plugin list
cordova-plugin-compat 1.2.0 "Compat" cordova-plugin-console 1.1.0 "Console" cordova-plugin-device 1.1.7 "Device" cordova-plugin-inappbrowser 1.7.2 "InAppBrowser" cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview" cordova-plugin-native-spinner 1.1.3 "Native Spinner" cordova-plugin-splashscreen 4.1.0 "Splashscreen" cordova-plugin-statusbar 2.4.1 "StatusBar" cordova-plugin-sunmi-inner-printer 1.1.0 "SunmiInnerPrinter" cordova-plugin-whitelist 1.3.3 "Whitelist" es6-promise-plugin 4.2.2 "Promise" ionic-plugin-deeplinks 1.0.15 "Ionic Deeplink Plugin" ionic-plugin-keyboard 2.2.1 "Keyboard"
- edit PATH/OF/YOUR/IONIC/PROJECT/platforms/android/build.gradle
dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile "com.sunmi:sunmiui:latest.release" <------ ADD THIS // SUB-PROJECT DEPENDENCIES START debugCompile(project(path: "CordovaLib", configuration: "debug")) releaseCompile(project(path: "CordovaLib", configuration: "release")) // SUB-PROJECT DEPENDENCIES END }
Tq sir, Its working tq so much sir, in that "printOriginalText" i want to print one html page , how can i do that
@gayu1712
convert your html page into bitmap, see https://stackoverflow.com/questions/21214620/render-html-text-to-bitmap-using-javascript-without-serverside-code
use the following to print the bitmap image as follows:
sunmiInnerPrinter.printBitmap(YOUR_BITMAP, width, height, function(okay){ console.log('okay: '+ JSON.stringify(okay)); }.bind(this), function(error){ console.log('ERROR: '+ JSON.stringify(error)); }.bind(this) );
@gayu1712
- convert your html page into bitmap, see https://stackoverflow.com/questions/21214620/render-html-text-to-bitmap-using-javascript-without-serverside-code
- use the following to print the bitmap image as follows:
sunmiInnerPrinter.printBitmap(YOUR_BITMAP, width, height, function(okay){ console.log('okay: '+ JSON.stringify(okay)); }.bind(this), function(error){ console.log('ERROR: '+ JSON.stringify(error)); }.bind(this) );
@tmalbonph Actually i want to bind a data from api after that i want to print that html page,is it possible in ionic3
@gayu1712 anything is possible. the printBitmap() only accept base64 string of a Window Bitmap image. You need to convert the sample code from here https://stackoverflow.com/questions/21214620/render-html-text-to-bitmap-using-javascript-without-serverside-code into a Windows Bitmap image.
You need to convert the sample code from her
@tmalbonph I get an error in this line " ctx.drawHTMLText(...html here...);" as does not exist on type , i want to install anyting for that, or anyother solution is there
@gayu1712 You need to convert the stackoverflow code into typescript form to use it
@gayu1712 You need to convert the stackoverflow code into typescript form to use it
@tmalbonph I can't get it, i try that but i dono how to do correctly, i want to print like a bill.
@gayu1712 On my latest project, I am using this modified plugin here https://github.com/tmalbonph/cordova-plugin-sunmi-inner-printer to print ticket for booking services and been using printBitmap() to print my client logo; using printOriginalText() to print ticket details; using printQRCode() to print the ticket reference number as QRCode and lineWrap(4) at the end of printing with no problem at all.
@gayu1712 On my latest project, I am using this modified plugin here https://github.com/tmalbonph/cordova-plugin-sunmi-inner-printer to print ticket for booking services and been using printBitmap() to print my client logo; using printOriginalText() to print ticket details; using printQRCode() to print the ticket reference number as QRCode and lineWrap(4) at the end of printing with no problem at all.
@tmalbonph Can u post your reference code ..for How to do that
@gayu1712 I am sorry. I can't do that. It was already own by my client ;-)
@gayu1712 I am sorry. I can't do that. It was already own by my client ;-)
@tmalbonph can u explain me how u change that code to .ts format
You can do something like:
save this as PATH/TO/YOUR/IONIC/PROJECT/src/app/htmltobitmap.module.ts
@Injectable() export class HtmlToBitmap extends CanvasRenderingContext2D {
public drawHTMLText(txt: string, options?: any) {
...
}
}
@tmalbonph If i use this "export class HtmlToBitmap extends CanvasRenderingContext2D" , i got illegal constructor error even i use super(); also i got the same error
@gayu1712 On my latest project, I am using this modified plugin here https://github.com/tmalbonph/cordova-plugin-sunmi-inner-printer to print ticket for booking services and been using printBitmap() to print my client logo; using printOriginalText() to print ticket details; using printQRCode() to print the ticket reference number as QRCode and lineWrap(4) at the end of printing with no problem at all.
@tmalbonph Can u post your reference code ..for How to do that
@tmalbonph In above u said printOriginalText() to print ticket details; , how could you do that by using an html tag,can u elaborate
@gayu1712 printOriginalText() is for printing text. The text is normally 32 characters long per line. The line width is 58mm (the maximum width of your printer's thermal paper). The text can consist of single line or multiple lines separated by line feed (0x0A). Printing via printOriginalText() is faster compare to printBitmap() and I think it will help to extend the life of your printer thermal unit, beyond its "Printer service life" of 50km.
@tmalbonph If i use this "export class HtmlToBitmap extends CanvasRenderingContext2D" , i got illegal constructor error even i use super(); also i got the same error
I don't get this error while I encoded it using Visual Studio Code version 1.27.2
found solution with this thread, thanks @tmalbonph
found solution with this thread, thanks @tmalbonph
Your welcome @gItSpLasHeR
found solution with this thread, thanks @tmalbonph
Hi, Did u find that in ionic3 , to print html page with api calling.
@tmalbonph If i use this "export class HtmlToBitmap extends CanvasRenderingContext2D" , i got illegal constructor error even i use super(); also i got the same error
I don't get this error while I encoded it using Visual Studio Code version 1.27.2
HI , Still know i cant print my html page and the same time when i clone the project , cordova -sunmi printer is failed to install after that i have to install separately, then only its working
@tmalbonph If i use this "export class HtmlToBitmap extends CanvasRenderingContext2D" , i got illegal constructor error even i use super(); also i got the same error
I don't get this error while I encoded it using Visual Studio Code version 1.27.2
HI , Still i know i cant print my html page and the same time when i clone the project , cordova -sunmi printer is failed to install after that i have to install separately, then only its working
Hi @gayu1712 Do I need to fix every error you have?
@tmalbonph If i use this "export class HtmlToBitmap extends CanvasRenderingContext2D" , i got illegal constructor error even i use super(); also i got the same error
I don't get this error while I encoded it using Visual Studio Code version 1.27.2
HI , Still i know i cant print my html page and the same time when i clone the project , cordova -sunmi printer is failed to install after that i have to install separately, then only its working
Hi @gayu1712 Do I need to fix every error you have?
Hi @tmalbonph i really need u r help, still getting same error , i dono how to print that html page
@tmalbonph If i use this "export class HtmlToBitmap extends CanvasRenderingContext2D" , i got illegal constructor error even i use super(); also i got the same error
I don't get this error while I encoded it using Visual Studio Code version 1.27.2
HI , Still i know i cant print my html page and the same time when i clone the project , cordova -sunmi printer is failed to install after that i have to install separately, then only its working
Hi @gayu1712 Do I need to fix every error you have?
Hi @tmalbonph still getting same error , i dono how to print that html page
@gayu1712 I am sorry; I have limited time this month to help.
Hi @tmalbonph , can you please help me with this. I am trying to make this plugin work with ionic1 app. When I tried with ionic3, it worked perfectly, but for ionic1, I am getting errors. Please help.
Hi @tmalbonph , can you please help me with this. I am trying to make this plugin work with ionic1 app. When I tried with ionic3, it worked perfectly, but for ionic1, I am getting errors. Please help.
Hi @saberprashant Can you post the error here.
@tmalbonph , It is showing this error:
Failed to load resource: net::ERR_FILE_NOT_FOUND (in innerprinter.js)
I am integrating like this:
main.html
under cordova.js file:
<script src="../plugins/cordova-sunmi-inner-printer/www/innerprinter.js"></script>
app.js
like this:
window.sunmiInnerPrinter.<methods>
@saberprashant
export PPWD=`pwd`
sudo mkdir -p /driver
sudo chown $USER:$USER /driver
sudo chmod 0700 /driver
cd /driver
git clone git@github.com:tmalbonph/cordova-plugin-sunmi-inner-printer.git
cd $PPWD/
gedit package.json
"cordova-android": "^6.3.0",
"cordova-plugin-sunmi-inner-printer": "file:/driver/cordova-plugin-sunmi-inner-printer",
"jquery": "^3.2.1",
@tmalbonph , I followed everything and I am getting this error on running 2nd last command -> cd $PPWD/
bash: cd: pwd/: No such file or directory
@saberprashant I am guessing that you have problem with pwd. You can do the following instead.
export PPWD=/PATH/TO/WHERE/YOUR/package.json
sudo mkdir -p /driver
sudo chown $USER:$USER /driver
sudo chmod 0700 /driver
cd /driver
git clone git@github.com:tmalbonph/cordova-plugin-sunmi-inner-printer.git
cd $PPWD/
gedit package.json
{
"cordova-android": "^6.3.0",
"cordova-plugin-sunmi-inner-printer": "file:/driver/cordova-plugin-sunmi-inner-printer",
"jquery": "^3.2.1",
}
Let me know if it works for you.
@saberprashant
"package.json"
for your ionic project and insert the following:{
"cordova-plugin-sunmi-inner-printer": "file:/driver/cordova-plugin-sunmi-inner-printer",
}
"*sunmi-inner-printer"
entry on your "package.json"
Hi @tmalbonph , thank you so much for your help. It worked with your repo. 🍻
Hi @tmalbonph , thank you so much for your help. It worked with your repo.
@saberprashant I am glad the changes I had made with "cordova-sunmi-inner-printer"
help your "SUNMI"
project.
- you need to declare the variables before any class declaration as follows:
declare var sunmiInnerPrinter: any;
- you need to use the "sunmiInnerPrinter" after ionViewDidLoad()
- if you want to see the error on using the "sunmiInnerPrinter", you enclose your code inside the try - catch block.
try { if (JSON.stringify(sunmiInnerPrinter) !== "{}") { return; } // it is safe to use sunmiInnerPrinter here } catch(err) { console.log("error: "+ JSON.stringify(err)); }
@tmalbonph i'm trying to use your plugin, after installing it in ionic 4 followed these steps but i still get that sunmiInnerPrinter is undefined i tried in every way possible but still doesn't work how do i fix that..?
@tmalbonph i'm trying to use your plugin, after installing it in ionic 4 followed these steps but i still get that sunmiInnerPrinter is undefined i tried in every way possible but still doesn't work how do i fix that..?
@ma851tos
If you want further help from me, please do the following:
Create an issue here cordova-plugin-sunmi-inner-printer
Create a question in Stack Overflow and mention the github issue you created in step 2.
Make sure you tag your "stackoverflow question"
with android, android-gradle, ionic3, and ionic4 tags.
Finally, post the link of the "stackoverflow question"
you have created in step 4, so I can properly response on it.
@tmalbonph i'm trying to use your plugin, after installing it in ionic 4 followed these steps but i still get that sunmiInnerPrinter is undefined i tried in every way possible but still doesn't work how do i fix that..?
@ma851tos
- If you want further help from me, please do the following:
- Create an issue here cordova-plugin-sunmi-inner-printer
- Create a question in Stack Overflow and mention the github issue you created in step 2.
- Make sure you tag your
"stackoverflow question"
with android, android-gradle, ionic3, and ionic4 tags.- Finally, post the link of the
"stackoverflow question"
you have created in step 4, so I can properly response on it.
thank you for you answer
i did it
https://stackoverflow.com/questions/56473958/use-sunmi-inner-printer-in-ionic
Please anyone help me, Using Cordova sunmi printer is working fine. But, i need Printer status before printing. Example, Validate printer status, Don't allow to do printer is not available and not ready or paper not available.
Thanks in Advance
Please anyone help me, Using Cordova sunmi printer is working fine. But, i need Printer status before printing. Example, Validate printer status, Don't allow to do printer is not available and not ready or paper not available.
Thanks in Advance
@saberprashant Please post your issue here: https://github.com/tmalbonph/cordova-plugin-sunmi-inner-printer/issues
Please anyone help me, Using Cordova sunmi printer is working fine. But, i need Printer status before printing. Example, Validate printer status, Don't allow to do printer is not available and not ready or paper not available. Thanks in Advance
@saberprashant Please post your issue here: https://github.com/tmalbonph/cordova-plugin-sunmi-inner-printer/issues
Okay sir, Please help me to solve sunmi printer validation
what is the use of printerStatusStartListener(); and what value is return ?
@tmalbonph I want to integrate pos bluetooth printer for merchant app Sunmi Can you help me please?
@tmalbonph I want to integrate pos bluetooth printer for merchant app Sunmi
@lunadeistanbul7 What kind of help do you want from me?
Hi Sir, I am using ionic3 app, for that i am using sunmi pos , i want to print a receipt , i installed the plugin successfully in android@6.3.0, after that i declare let sunmiInnerPrinter: any; before @component in that particular .ts page and i call as " sunmiInnerPrinter.printOriginalText("Hello Printer"); " , i got error as "Uncaught (in promise): ReferenceError: sunmiInnerPrinter is not defined" can u pls explain how can i clear this issue ASAP, thank you,