A JavaScript wrapper for interacting with Zebra printers using the Browser Print API. This package provides functionalities to retrieve available printers, set a default printer, check printer status, and send print commands.
npm install zebra-browser-print
import ZebraBrowserPrintWrapper from "zebra-browser-print";
const printer = new ZebraBrowserPrintWrapper();
printer.getAvailablePrinters()
.then(printers => console.log("Available Printers:", printers))
.catch(error => console.error("Error fetching printers:", error));
printer.getDefaultPrinter()
.then(device => console.log("Default Printer:", device))
.catch(error => console.error("Error fetching default printer:", error));
const myPrinter = { name: "Zebra Printer", deviceType: "USB", connection: "USB", uid: "12345", provider: "Zebra", manufacturer: "Zebra Technologies", version: 0 };
printer.setPrinter(myPrinter);
const selectedPrinter = printer.getPrinter();
console.log("Selected Printer:", selectedPrinter);
printer.checkPrinterStatus()
.then(status => console.log("Printer Status:", status))
.catch(error => console.error("Error checking printer status:", error));
printer.print("Hello, Zebra!")
.then(() => console.log("Print Successful"))
.catch(error => console.error("Error printing:", error));
printer.printLabel("Sample Label Text")
.then(() => console.log("Label Printed Successfully"))
.catch(error => console.error("Error printing label:", error));
Retrieves a list of available Zebra printers.
Fetches the default printer settings.
Sets the active printer.
Gets the currently selected printer.
Checks the printer status and returns error messages if any.
Sends raw data to the printer.
Reads data from the printer.
Sends text to the printer for printing.
Prints a label using Zebra label formatting.
- If no printers are available, an error is thrown.
- If the default printer cannot be found, an error is thrown.
- If a printer operation fails, an error message is returned.
MIT License