Socket
Socket
Sign inDemoInstall

zebra-browser-print-wrapper

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    zebra-browser-print-wrapper

Zebra Browser Print Javascript Wrapper


Version published
Weekly downloads
2.2K
decreased by-9.05%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Zebra Browser Print Wrapper

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

Install

Install the module in your project via YARN

yarn add zebra-browser-print-wrapper

Or NPM

npm i zebra-browser-print-wrapper

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()

Example

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

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);

Keywords

FAQs

Last updated on 16 Jun 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc