zebra-browser-print-wrapper-extended
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Zebra Browser Print Wrapper Extended

This package is a wrapper for the Zebra Browser Print and allows you to easily integrate your Zebra printers with web applications like (ReactJS).

This is a fork from https://github.com/lhilario/zebra-browser-print-wrapper/ with merged pr's from https://github.com/naxels and https://github.com/Adam-Sehlin as the repository was not maintained by https://github.com/lhilario

Install

Install the module in your project via YARN

yarn add zebra-browser-print-wrapper-extended

Or NPM

npm i zebra-browser-print-wrapper-extended

Available Methods

getAvailablePrinters()

Return a list of the current available printers

getDefaultPrinter()

Gets the current default printer

setPrinter()

Sets the printer field

getPrinter()

Returns the printer field

checkPrinterStatus()

Returns an object indicating if the printer is ready and if not returns the error.

Returned object:

{
 isReadyToPrint: boolean;
 errors: string
}

Possible errors:

  • Paper out
  • Ribbon Out
  • Media Door Open
  • Cutter Fault
  • Printhead Overheating
  • Motor Overheating
  • Printhead Fault
  • Incorrect Printhead
  • Printer Paused
  • Unknown Error
print(str)

Prints a text string.

You can use this method with simple text or add a string using the ZPL language.

printBlob(Blob)

Prints a Blob.

This also allows printing using the EPL language.

In order to print pdf ensure the printer emulation setting is set to pdf

printUrl(str)

Grab's the URL's content as Blob and send to the Printer.

This also allows printing EPL.

Example

// Import the zebra-browser-prit-wrapper package
const  ZebraBrowserPrintWrapper = require('zebra-browser-print-wrapper-extended');

const printBarcode = async (serial) => {
    try {

        // Create a new instance of the object
        const browserPrint =  new ZebraBrowserPrintWrapper();

        // Select default printer
        const defaultPrinter =  await browserPrint.getDefaultPrinter();
    
        // Set the printer
        browserPrint.setPrinter(defaultPrinter);

        // Check printer status
        const printerStatus = await browserPrint.checkPrinterStatus();

        // Check if the printer is ready
        if(printerStatus.isReadyToPrint) {

            // ZPL script to print a simple barcode
            const zpl = `^XA
                        ^BY2,2,100
                        ^FO20,20^BC^FD${serial}^FS
                        ^XZ`;

            browserPrint.print(zpl);
        } else {
        console.log("Error/s", printerStatus.errors);
        }

    } catch (error) {
        throw new Error(error);
    }
};

const serial = "0123456789";

printBarcode(serial);

/zebra-browser-print-wrapper-extended/

    Package Sidebar

    Install

    npm i zebra-browser-print-wrapper-extended

    Weekly Downloads

    255

    Version

    1.0.1

    License

    GPL-3.0

    Unpacked Size

    23.6 kB

    Total Files

    8

    Last publish

    Collaborators

    • lensart