-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (31 loc) · 1.07 KB
/
index.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
import {NativeModules} from "react-native";
const {PaxPrinter} = NativeModules;
export const FULL_CUT = 0;
export const PARTIAL_CUT = 1;
const FontSizes = {XXS: 'XXS', XS: 'XS', SM: 'SM', MD: 'MD', LG: 'LG', XL: 'XL'}
const Alignments = {LEFT: 'LEFT', CENTER: 'CENTER', RIGHT: 'RIGHT'}
const TextStyles = {NORMAL: 'NORMAL', BOLD: 'BOLD', ITALIC: 'ITALIC', UNDERLINE: 'UNDERLINE'}
const getSafeCutMode = (cutMode) => cutMode === undefined ? FULL_CUT : cutMode;
export function printString(text, cutMode) {
PaxPrinter.initPrinter();
PaxPrinter.setGrayLevel(3);
PaxPrinter.addTextLine(text);
PaxPrinter.start();
}
export function printPage(receiptConfig){
const json = JSON.stringify(receiptConfig);
PaxPrinter.initPrinter();
PaxPrinter.setGrayLevel(3);
PaxPrinter.addPage(json);
PaxPrinter.start();
}
export function savePageAsImage(receiptConfig){
const json = JSON.stringify(receiptConfig);
PaxPrinter.savePageAsImage(json);
}
export const PageLineOptions = {
FONT_SIZES: FontSizes,
ALIGNMENTS: Alignments,
TEXT_STYLES: TextStyles,
}
export default PaxPrinter;