Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

bpac-js

yeasir01508MIT2.2.0TypeScript support: included

High level API for interacting with the Brother BPAC SDK

bpac, brother, print, barcode, web print, brother-label-printer, brother-ql

readme

bPac logo

Brother bPac printer SDK for Web Browsers

NPM Version GitHub Actions Workflow Status GitHub License NPM Downloads

Overview

The Brother bPac printer SDK for Web Browsers simplifies the integration of the b-PAC SDK, providing a user-friendly interface for common tasks such as printing and obtaining image data. This project aims to enhance accessibility through modern JavaScript practices and thorough documentation, making it a valuable tool for developers working on web-based printing solutions

Features

  • Modern JavaScript: The SDK has been refactored to use modern JavaScript practices, making it more accessible for developers familiar with contemporary web development.

  • Documentation: Comprehensive documentation has been added to the codebase, ensuring that developers have clear insights into the functionality and usage of each module.

  • IntelliSense Support: With well-documented code and consistent naming conventions, developers can enjoy improved IntelliSense support for a smoother coding experience.

Prerequisites

Before using the Brother Printer SDK for Web Browsers, ensure you meet the following prerequisites:

  1. Supported Printer Model:

    • Check the list of supported printer models here. Ensure that your Brother printer is on the list for compatibility with this SDK. check src/vendor folder to identify current bpac version (example: bpac-v3.4.js).
  2. Driver Installation:

    • Install the appropriate printer driver for your Brother printer on your system. Visit the Brother Solutions Center to download and follow the installation instructions provided by Brother.
  3. Template Printing Setup:

    • Ensure that you can successfully print directly from the template file. This may involve configuring your printer settings and your template file.
  4. b-PAC Client Component:

    • Before using the Brother Printer SDK for Web Browsers, you will also need to install the BPac Client. This client is essential for enabling communication between your browser and the Brother printer.
    • Download and install the BPac Client from the following link: BPac Client
  5. Brother b-PAC Extension:

Ensure that all prerequisites are met to guarantee a seamless experience.

Getting Started

1. Install the package:

Package Manager

$ npm i bpac-js

Content Delivery Network - Latest

https://cdn.jsdelivr.net/npm/bpac-js@latest/dist/index.js

The latest flag retrieves the most recent package version, potentially including breaking changes. In production environments, it is strongly recommended to use explicit version numbers to maintain predictable builds.

2. Explore Documentation:

Visit the docs section in this repository to explore detailed guides and examples.

3. Contribute:

If you encounter issues or have suggestions, feel free to contribute to the project. Your input is highly valued!

Usage

// Script File
import BrotherSdk from "https://cdn.jsdelivr.net/npm/bpac-js@latest/dist/index.js";

const printBtn = document.getElementById("print-btn");

const shoeLabel = new BrotherSdk({
    templatePath: "C:/Templates/shoe-template.lbx",
    exportPath: "C:/Users/YourProfile/Desktop/Exported Labels/",
});

// The keys and values must match the objects/types in the template file.
const data = {
    title: "Air Force 1",
    price: "$149.99",
    barcode: "091207567724",
    date: new Date("2024-1-20"),
};

const options = {
    copies: 1, // Optional - Defaults: 1
    printName: "Air Force One Label", // Optional - Defaults: BPAC-Document
    highResolution: true // Optional
}

const sendToPrinter = async () => {
    try {
        const isPrinted = await shoeLabel.print(data, options);
        console.log({isPrinted})
    } catch (error) {
        console.log({error})
    }
};

printBtn.addEventListener("click", sendToPrinter);

Acknowledgments

Special thanks to Brother for their QL Series Printer SDK. This project wouldn't be possible without their technology.

Happy coding with Brother QL Series Printer SDK for Web Browsers! 🚀

License

This project is licensed under the MIT License.

changelog

bpac-js

2.2.0

Minor Changes

  • 6ec43e2: ### Summary

    • Improved error handling
    • Switched test framework from Mocha to Jest
    • Updated internal packages and dependencies
    • Added support for printing multiple labels
    • Improved documentation
    • Patched a bug where QR codes were not being populated
    • Added limited support for printStatus function (beta)

2.1.0

Minor Changes

  • b7b2085: Initial stable release

2.0.4

Patch Changes

  • 89b83b0: better error handling and documentation in codebase.

2.0.3

Patch Changes

  • aa95a74: fix import from root

2.0.2

Patch Changes

  • 748101e: ignore build files for prod

2.0.1

Patch Changes

  • 07947c6: modify git build steps

2.0.0

Major Changes

  • c2bd623: Initial Release