@nfails/bpac-js
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

bpac-js

This is a library to print on Brother Thermal-Printer with nodejs. This works by sending the commands to the official b-PAC-client Component.

Requierements

b-Pac Client Component

The official b-PAC Client Component Brother Download Website must be installed.

If the Installation-Location differs from the Default-Location it can happen, that the path to the bpacHost.exe has to be set manually in your program.

BpacConfig.bpacHostPath = "<path to bpacHost.exe>"

Printer Driver

Install the appropriate printer driver for your Brother printer on your system. This can also be found on the official Brother Website.

Usage

Example - Export

import { BpacConfig, BpacDocument, ExportType } from '@nfails/bpac-js';

BpacConfig.bpacHostPath = "<path to bpacHost.exe>"
async function exportFile(lastname: string) {
const doc = await BpacDocument.Open("<path to lbx template>")
const o = await doc.GetObject("objLastName");
await o.setText(lastname);
await doc.Export(ExportType.bexBmp, `./test.bmp`, 100)
await doc.Close()
}

exportFile('TEST').then(() => console.log('success'))

Example - Print

async function printLabel(lastName) {
  const doc = await BpacDocument.Open("<path to lbx template>")
  const o = await doc.GetObject("objLastName");
  await doc.SetPrinter(<PrinterName>, false);
  await o.setText(lastName);
  await doc.StartPrint("Sample Label");
  await doc.PrintOut(1);
  await doc.EndPrint();
  await doc.Close();
}

Contribute

If you encounter issues or have suggestions, feel free to contribute to the project.

Readme

Keywords

Package Sidebar

Install

npm i @nfails/bpac-js

Weekly Downloads

3

Version

2.0.2

License

MIT

Unpacked Size

57.6 kB

Total Files

16

Last publish

Collaborators

  • nfails