@nfails/bpac-js
v2.0.3
Published
Print on Brother Thermal-Printer via Nodejs. Some of the Bpac functionality is already available. The Server/Client also has to Install the official bpac-client to work with this library.
Downloads
54
Readme
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
Install
npm install @nfails/bpac-js
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.