esoftplay-android-print
Advanced tools
Comparing version 0.0.102 to 0.0.103
63
index.ts
@@ -6,3 +6,2 @@ | ||
export type BarcodeType = "UPC-A" | "UPC-E" | "EAN13" | "EAN8" | "CODE39" | "ITF" | "CODABAR" | "CODE93" | "CODE128" | ||
@@ -13,4 +12,5 @@ export type Justification = "LEFT" | "CENTER" | "RIGHT" | ||
export type qrsize = 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | ||
let CHARSIZE = 32; | ||
export default { | ||
const PRINTER = { | ||
connectBluetooth: (macAdress: string, cb: (status: 1 | 0) => void) => PrinterAndroidLibrary.connectBluetooth(macAdress, cb), | ||
@@ -20,6 +20,6 @@ listBluetooth: (cb: (printers: any[]) => void) => PrinterAndroidLibrary.listBluetooth(cb), | ||
openCashdrawer: () => PrinterAndroidLibrary.openCashdrawer(), | ||
printBarcode: (barcodeType: BarcodeType, data: string, height: number, barSize: number, align: Justification) => PrinterAndroidLibrary.printBarcode(barcodeType, data, height, barSize, align), | ||
printQRCode: (data: string, level: level, size: qrsize, align: Justification) => PrinterAndroidLibrary.printQRCode(data, level, size, align), | ||
printTextBase: (text: string, align: Justification, IAttribute: attr, size: number) => PrinterAndroidLibrary.printTextBase(text, align, IAttribute, size), | ||
printImage: (base64: string, width: number, align: Justification) => PrinterAndroidLibrary.printImage(base64, width, align), | ||
printBarcode: (barcodeType: BarcodeType, data: string, height: number, barSize: number, align: string) => PrinterAndroidLibrary.printBarcode(barcodeType, data, height, barSize, align), | ||
printQRCode: (data: string, level: level, size: qrsize, align: string) => PrinterAndroidLibrary.printQRCode(data, level, size, align), | ||
printTextBase: (text: string, align: string, IAttribute: attr, size: number) => PrinterAndroidLibrary.printTextBase(text, align, IAttribute, size), | ||
printImage: (base64: string, width: number, align: string) => PrinterAndroidLibrary.printImage(base64, width, align), | ||
setPaperSize: (size: 32 | 48) => PrinterAndroidLibrary.setPaperSize(size), | ||
@@ -29,1 +29,52 @@ cutPaper: () => PrinterAndroidLibrary.cutPaper(), | ||
} | ||
export default { | ||
LEFT: "LEFT", | ||
CENTER: "CENTER", | ||
RIGHT: "RIGHT", | ||
initPrinter(mac: string, cb: (status: 0 | 1) => void) { | ||
PRINTER.connectBluetooth(mac, cb) | ||
}, | ||
setPaperSize(size: 32 | 48) { | ||
PRINTER.setPaperSize(size) | ||
CHARSIZE = size; | ||
}, | ||
getPrinterList(cb: (printers: any[]) => void) { | ||
PRINTER.listBluetooth(cb) | ||
}, | ||
printImage(base64: string, width: number, align: Justification) { | ||
PRINTER.printImage(base64, width, align); | ||
}, | ||
addNewLine(count: number = 1) { | ||
let enters = new Array(count).fill('\n').join('') | ||
PRINTER.printTextBase(enters, "LEFT", "DEFAULT", 0) | ||
}, | ||
openDrawer() { | ||
PRINTER.openCashdrawer() | ||
}, | ||
printTextln(text: string, align: Justification) { | ||
PRINTER.printTextBase(text, align, "DEFAULT", 0) | ||
}, | ||
printTextJustify(text1: string, text2: string) { | ||
let adder = CHARSIZE - (text1.length + text2.length) | ||
let newText = text1 + new Array(adder).fill(" ").join("") + text2 | ||
PRINTER.printTextBase(newText, "LEFT", "DEFAULT", 0) | ||
}, | ||
printTextJustifyBold(text1: string, text2: string) { | ||
let adder = CHARSIZE - (text1.length + text2.length) | ||
let newText = text1 + new Array(adder).fill(" ").join("") + text2 | ||
PRINTER.printTextBase(newText, "LEFT", "BOLD", 0) | ||
}, | ||
printTextlnNormal(text: string, align: Justification) { | ||
PRINTER.printTextBase(text, align, "DEFAULT", 0) | ||
}, | ||
printTextlnBold(text: string, align: Justification) { | ||
PRINTER.printTextBase(text, align, "BOLD", 0) | ||
}, | ||
cutPaper() { | ||
PRINTER.cutPaper() | ||
}, | ||
feed() { | ||
PRINTER.printTextBase("\n\n\n", this.CENTER, "DEFAULT", 0) | ||
} | ||
} |
{ | ||
"name": "esoftplay-android-print", | ||
"version": "0.0.102", | ||
"version": "0.0.103", | ||
"description": "Printing ", | ||
@@ -5,0 +5,0 @@ "main": "./index.ts", |
384128
819