Open sebmahel opened 5 years ago
//Workarround
const fs = require('fs'); const os = require('os'); const JsBarcode = require('jsbarcode'); const Canvas = require("canvas"); const printer = require('node-native-printer');
let canvas = Canvas.createCanvas(); JsBarcode(canvas, "Hello");
var buf = canvas.toBuffer(); fs.writeFileSync( os.tmpdir() + "/tmp.png", buf);
let options = { "collate": true, "landscape": true, "paperSize": "Letter" }
printer.print(os.tmpdir() + "/tmp.png", options, 'PrinterName')
Example
const JsBarcode = require('jsbarcode'); const Canvas = require("canvas"); const printer = require('node-native-printer');
let canvas = Canvas.createCanvas(); JsBarcode(canvas, "Hello");
let options = { "collate": true, "landscape": true, "paperSize": "Letter" }
printer.printCanvas(canvas, options, 'PrinterName')