UNPKG

dynamicsmobile

Version:

Allows development of off-line mobile and web business apps over the Dynamics Mobile platform. More info on https://www.dynamicsmobile.com

54 lines 2.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MobilePrintService = void 0; const tslib_1 = require("tslib"); const print_service_1 = require("../lib-core/print-service"); const injectable_1 = require("../ioc/injectable"); const dms_platform_bridge_factory_1 = require("../platform/dms-platform-bridge-factory"); const js_base64_1 = require("js-base64"); let MobilePrintService = exports.MobilePrintService = class MobilePrintService extends print_service_1.PrintService { print(options) { return tslib_1.__awaiter(this, void 0, void 0, function* () { if (!options.printerName) throw new Error('PrintService.print requires argument printerName'); if (!options.textToPrint) throw new Error('PrintService.print requires argument textToPrint'); if (!options.pageWidth) throw new Error('PrintService.print requires argument pageWidth'); if (!options.pageHeight) throw new Error('PrintService.print requires argument pageHeight'); if (!options.encoding) throw new Error('PrintService.print requires argument encoding'); if (options.secureConnection == true || options.secureConnection == null || options.secureConnection == undefined) options.insecure = "0"; else options.insecure = "1"; const encodedContent = js_base64_1.Base64.encode(options.textToPrint); options.textToPrint = encodedContent; options.isBase64Encoded = true; return (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("print", options); }); } printImage(options) { return tslib_1.__awaiter(this, void 0, void 0, function* () { if (!options.printerName) throw new Error('PrintService.printImage requires argument printerName'); if (!options.data) throw new Error('PrintService.printImage requires argument data'); if (!options.data.command) throw new Error('PrintService.printImage requires argument data.command'); if (!options.data.commandData) throw new Error('PrintService.printImage requires argument data.commandData'); return (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("printImage", options); }); } getPrinters() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.DeviceService.getBTDevices(); }); } }; exports.MobilePrintService = MobilePrintService = tslib_1.__decorate([ (0, injectable_1.Injectable)() ], MobilePrintService); //# sourceMappingURL=mobile-print-service.js.map