Giter Club home page Giter Club logo

node-brother-pt-labeler's Introduction

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.

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.

node-brother-pt-labeler's People

Contributors

driehle avatar

Stargazers

底なし沼の魔女 avatar  avatar Chrysanthos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.