bpac-react
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

bpac-react

JavaScript module for communicating with the Brother QL-series label printers.
Currently the module has no typings whatsoever, as the internal code is dug up from old Brother instructions (from when JScript was a thing!). Anyone brave enough to figure out all the one-letter variables inside is more than welcome to contribute.

Until then, just follow the steps below to print your labels.

Installation

Use npm to install the package.

npm install bpac-react

Your client computer will also need the b-PAC SDK.
IMPORTANT NOTE: Only the 32-bit versions of the b-PAC SDK work. Don't bother installing the 64-bit versions.

You can create templates for your labels with the P-Touch Editor (the editor is device-specific).

Usage

import { IDocument } from "bpac-react";

const printAFile = async ()
=> {
  const objDoc = bpac.IDocument;
  const ret = await objDoc.Open("C:\absolute\path\to\file\template.lbx");
  // most of the functions from the SDK return true/false for success
  if(ret === true){ 

     // Set the data in a barcode/QR code inside your template file
     await objDoc.SetBarcodeData(
            await objDoc.GetBarcodeIndex("some-barcode"),
            "The text to be inside the barcode"
          );
     
     // Set the text in a Text object inside your template file
     (await objDoc.GetObject("some-text")).Text = "Your Text";

     // Start the print
     await objDoc.StartPrint('', 0);
     await objDoc.PrintOut(1, 0);
     await objDoc.EndPrint();
     await objDoc.Close();
  }
}

Contributing

Any contribution is absolutely welcome. Create a pull request and I'll merge it ASAP.

License

MIT

Package Sidebar

Install

npm i bpac-react

Weekly Downloads

4

Version

1.0.2

License

MIT

Unpacked Size

157 kB

Total Files

6

Last publish

Collaborators

  • kkx64