Skip to content

Print

Printing to connected printers

Kind: global namespace

print.printLabelImage(image)

Print a 300 DPI image on the shipping label printer, centered on a 4x6 inch label. Image is automatically scaled to 200 DPI if required by the printer.

Kind: static method of print

Param Type Description
image ArrayBuffer | Buffer | Uint8Array | string | Jimp image data, as a Jimp image object, raw PNG bytes, or a URL (http/https) string. 1200x1800 or 800x1200 images are scaled to 4x6 inches. Other image sizes are assumed to be 300 DPI and are centered on the shipping label. Image orientation is rotated to match the label orientation.

print.getReceiptPrinter() ⇒ Promise.<Object>

Get the receipt printer interface. See the ReceiptPrinter docs for available functions.

Kind: static method of print

print.printReceiptData(data)

Send raw data (generated by the printer interface) to the receipt printer.

Kind: static method of print

Param Type Description
data string | Uint8Array | Array.<string> | Array.<Uint8Array> Data to send to printer.

print.imageToBitmap(jimpImage, [dpiFrom], [dpiTo]) ⇒ Object

Convert a Jimp image object to 1-bit monochrome image data before sending image data to a printer interface. Optionally scales the image to a different DPI before conversion.

Kind: static method of print
Returns: Object - - Example: {width: 300, height: 200, img: Uint8Array}. Pass img to drawImage on a printer interface.

Param Type Default Description
jimpImage Jimp
[dpiFrom] number 300 Original image DPI.
[dpiTo] number 300 New image DPI.

print.printDocument(data, [printer]) ⇒ Promise

Send a file to a normal printer, using a print dialog. Supports HTML, PDF, and plain text. Auto-detects HTML by looking for <!doctype html> or <html> (case insensitive) in the first 50 bytes/characters of the data. Auto-detects PDF by looking for %PDF at the start of the data. Assumes plain text if the autodetection logic doesn't find a match.

Kind: static method of print
Returns: Promise - Resolves around the time the print dialog opens (or the print process is starting, for silent print).

Param Type Default Description
data Array | string | Uint8Array Text or binary data. If an array, the array elements will be merged together. Array elements must be strings or Uint8Arrays.
[printer] string "\"\"" blank string to show a print dialog, or a printer name to silently print without a dialog.