Skip to content

vikavorkin/bpac-react

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.8%
  • TypeScript 0.2%