Skip to content

feat: add zebra printer - #120

Draft
ji5485 wants to merge 2 commits into
seokju-na:mainfrom
ji5485:add-zebra-printer
Draft

feat: add zebra printer#120
ji5485 wants to merge 2 commits into
seokju-na:mainfrom
ji5485:add-zebra-printer

Conversation

@ji5485

@ji5485 ji5485 commented Nov 6, 2025

Copy link
Copy Markdown

Summary

This PR adds Zebra(ZPL-based) printer.
Enabled ZPL printing without manual coordinate management, making it behave like ESC/POS for easier layout handling.


Changes

  • Printer interface
    • Added line(width: number, character?: string): this method.
      • Prevents long command strings when Line component calls text() repeatedly.
      • Provides a ZPL-optimized way to render horizontal lines.
    • Added convertTextAlignInRow(align: Align): Align method.
      • Ensures correct alignment mapping for each Text component within a Row.
  • BasePrinter class
    • Implemented line() and convertTextAlignInRow() methods with default behaviors.
  • Line.print
    • Updated to call printer.line() instead of multiple printer.text() calls.
  • Row.print
    • Updated to use printer.convertTextAlignInRow() when rendering text at each position.
  • ZebraPrinter class
    • Added full implementation of ZPL-compatible printer with the following methods:
      • setCharacterSet(set: CharacterSet): this;
      • setTextFont(font: TextFont): this;
      • setTextBold(bold: boolean): this;
      • setTextSize(width: TextSize, height: TextSize): this;
      • setTextUnderline(underline: TextUnderline): this; (Not officially supported by ZPL, but could be implemented through non-standard or workaround methods.)
      • setTextNormal(): this;
      • setAlign(align: Align): this;
      • invert(enabled: boolean): this; (Not officially supported by ZPL, but could be implemented through non-standard or workaround methods)
      • text(data: string): this;
      • line(width: number, character?: string): this;
      • raw(data: Uint8Array): this;
      • line(character: string, width: number): this;
      • newLine(): this;
      • cut(partial?: boolean): this; (not supported)
      • image(image: Image, options?: ImageToRasterOptions): this; (to be implemented)
      • qrcode(data: string, options?: QRCodeOptions): this; (to be implemented)
      • barcode(data: string, type: BarcodeType, options?: BarcodeOptions): this; (to be implemented)
      • cashdraw(pin: CashDrawerPin): this; (not supported)
      • initialize(): this;
      • getData(): Uint8Array;
      • clear(): this;
      • debug(): this;
      • convertTextAlignInRow(align: Align): Align;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant