Initialize the Printer class
mainTo use the library, instantiate the Printer class by providing an Adapter (e.g., USB, Network, or SerialPort) and a PrinterOptions object. The Printer class manages an internal buffer of ESC/POS commands which are sent to the hardware when flush() is called.
PrinterOptions:
encoding(string, optional): The character encoding to use for text (defaults toGB18030).width(number, optional): The printer width in characters (defaults to48).
import Printer from '@node-escpos/core/Printer';
import USBAdapter from '@node-escpos/usb-adapter';
const adapter = new USBAdapter();
const options = { encoding: 'utf8', width: 42 };
const printer = new Printer(adapter, options);