0.1.2 • Published 2 years ago

brother-pt-labeler v0.1.2

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
-
Last release
2 years ago

brother-pt-labeler

A node.js library to print labels on a Brother label printer using the Internet Printing Protocol (IPP).

How to print a PNG file

First, you will need the IP address of your printer. The port for IPP is usually 631 and the path is usually /ipp/print. Please refer to your printer's manual for further information. Next, you will need a PNG file to print. Currently, PNG is the only file format supported by this library.

Existing PNG

const { printPngFile } = require('brother-pt-labeler');
const printerUrl = 'http://192.168.178.71:631/ipp/print';
const tapeWidth = 12;

printPngFile(printerUrl, `./samples/name-tag-${ tapeWidth }mm.png`, { 
  tapeWidth,
  highResolution: false,  
});

Create PNG using node-canvas and print using printBuffer command:

const { printBuffer } = require('brother-pt-labeler');
const { createCanvas, Image } = require('canvas');
const util = require('util');
const pngparse = require('pngparse');

const printerUrl = 'http://192.168.178.71:631/ipp/print';
const tapeWidth = 18;
const tapeWidthDots = 128; // 18mm
  
const canvas = createCanvas(400, tapeWidth);
const ctx = canvas.getContext('2d', { pixelFormat: 'A1' });
ctx.antialias = 'none';
ctx.font = `50px Arial`;
ctx.fillStyle = 'rgba(0,0,0,1)';
ctx.fillText('This is a test', 0, 0);
const palette = new Uint8ClampedArray([
  255, 255, 255, 255,
  0,  0,  0, 255,
]);
printBuffer(printerUrl, canvas.toBuffer('image/png', { palette },
  { 
    tapeWidth,
    highResolution: false,  
  },
));

See the samples folder example png's.

PNG height vs Tape Width

Tape WidthHeight in pixels
3.5mm24
6mm42
9mm64
12mm84
18mm128
24mm170

Considerations

Since this library is based on IPP it needs (raw, i.e. TCP) network access. This limitation implies that you cannot use this library in a web browser, where Javascript can only do HTTP/WebSocket requests. You can use this library on the server-side or in an ElectronJS desktop application.

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago