react-native-esc-pos-printer
Version:
An unofficial React Native library for printing on an EPSON TM printer with the Epson ePOS SDK for iOS and Epson ePOS SDK for Android
39 lines (38 loc) • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.addViewShot = addViewShot;
var _reactNative = require("react-native");
var _index = require("../constants/index.js");
async function addViewShot(printer, {
width,
viewNode
}) {
let captureRef = null;
try {
const RNViewShot = require('react-native-view-shot');
captureRef = RNViewShot.captureRef;
} catch (error) {}
if (!captureRef) {
console.error('Install react-native-view-shot to use addViewShot');
return;
}
const {
value: paperWidth
} = await printer.getPrinterSetting(_index.PrinterConstants.PRINTER_SETTING_PAPERWIDTH);
const imageBaset64Uri = await captureRef(viewNode, {
result: 'base64'
});
await printer.addImage({
source: {
uri: 'data:image/png;base64,' + imageBaset64Uri
},
color: _index.PrinterConstants.COLOR_4,
mode: _index.PrinterConstants.MODE_GRAY16,
halftone: _index.PrinterConstants.HALFTONE_THRESHOLD,
brightness: _reactNative.Platform.OS === 'ios' ? 0.3 : 0.1,
width: width || _index.FULL_IMAGE_WIDTH_RATIO * paperWidth
});
}
//# sourceMappingURL=addViewShot.js.map