@vaju/image-thermal-printer
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

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 and 300.
  • 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

Readme

Keywords

none

Package Sidebar

Install

npm i @vaju/image-thermal-printer

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

15 kB

Total Files

31

Last publish

Collaborators

  • vaju