@vaju/image-thermal-printer
v0.2.0
Published
(Experimental, Pure ESM)
Downloads
26
Readme
image-thermal-printer
(Experimental, Pure ESM)
Install
npm i @vaju/image-thermal-printer
Usage
import { generatePrintCommandsForImage, generatePrintCommandsForCanvas } from '@vaju/image-thermal-printer';
// To print from image
const printContent: Uint8Array = await generatePrintCommandsForImage('/the-2-time.webp', {
cutAfterPrint: true,
newLinesAfterImage: 3,
printerWidthInPx: 300,
});
// To print from canvas
// Note that the canvas's with should match the `printerWidthInPx`
// Else it won't print
const printContent: Uint8Array = await generatePrintCommandsForCanvas(htmlCanvasElement, {
cutAfterPrint: true,
newLinesAfterImage: 3,
});
FAQ
How to find printerWidthInPx
?
px = mm * dpi / 25.4
- Common dpi values are
200
and300
. - Common mm values are 58mm (... need to find out). But in reality you have to subtract ~10mm as margin for both sides. If your rendered images is more than the maximum pixes available in printer, the printer crashes. Then you have to restart your printer.
Eg:
- 200 dpi
- 58 mm - 10mm = 48mm
- gives 377px
License
MIT © Vajahath Ahmed