-
Add JSbarcode Link to you index.html
<script src="https://cdn.jsdelivr.net/npm/ [email protected]/dist/barcodes/JsBarcode.code128.min.js"></script>
-
call the JsBarcode function in typescript
`JsBarcode("#barcode", "193 1889");`
-
Add canvas to your HTML file with id
barcode
<canvas id="barcode"></canvas>
-
Convert the Canvas into Base64
const canvas:any = document.getElementById('barcode'; const dataURL =canvas.toDataURL();
-
Call DateCSPrinter PrintImage() function
let options:printImageOptions={ dataURL: dataURL, //base64 width: canvas.width, height: canvas.height, num:1 } window.DatecsPrinter.printImage((options)=>{ alert('Printing works!'); let jsonString = JSON.stringify(options); console.log('options',options); alert('JSON Data '+ jsonString); },err=>{ console.log('error occured',err); alert('something went wrong!'); })
-
And Thats it..!!
ghayyas / printbarcode Goto Github PK
View Code? Open in Web Editor NEWSimple demo for barcode Printer