forked from AlexLealLuz/cordova-plugin-datecs-printer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
printer.js
77 lines (74 loc) · 3.25 KB
/
printer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
var exec = require('cordova/exec');
var printer = {
platforms: ['android'],
isSupported: function() {
if (window.device) {
var platform = window.device.platform;
if ((platform !== undefined) && (platform !== null)) {
return (this.platforms.indexOf(platform.toLowerCase()) >= 0);
}
}
return false;
},
listBluetoothDevices: function(onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'listBluetoothDevices', []);
},
connect: function(address, onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'connect', [address]);
},
disconnect: function(onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'disconnect', []);
},
flush: function(onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'flush', []);
},
printReceipt: function(charset, text, image, width, height, align, footer, linesFeed, onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'printReceipt', [charset, text, image, width, height, align, footer, linesFeed]);
},
feedPaper: function(lines, onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'feedPaper', [lines]);
},
printText: function(text, charset, onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'printText', [text, charset]);
},
printSelfTest: function (onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'printSelfTest', []);
},
getStatus: function (onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'getStatus', []);
},
getTemperature: function (onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'getTemperature', []);
},
setBarcode: function (align, small, scale, hri, height, onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'setBarcode', [align, small, scale, hri, height]);
},
printBarcode: function (type, data, onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'printBarcode', [type, data]);
},
printQRCode: function (size, eccLvl, data, onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'printQRCode', [size, eccLvl, data]);
},
printImage: function (image, width, height, align, onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'printImage', [image, width, height, align]);
},
drawPageRectangle: function (x, y, width, height, fillMode, onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'drawPageRectangle', [x, y, width, height, fillMode]);
},
drawPageFrame: function (x, y, width, height, fillMode, thickness, onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'drawPageFrame', [x, y, width, height, fillMode, thickness]);
},
selectPageMode: function (onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'selectPageMode', []);
},
selectStandardMode: function (onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'selectStandardMode', []);
},
setPageRegion: function (x, y, width, height, direction, onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'setPageRegion', [x, y, width, height, direction]);
},
printPage: function (onSuccess, onError) {
exec(onSuccess, onError, 'DatecsPrinter', 'printPage', []);
}
};
module.exports = printer;