@schie/fluent-zpl - v0.10.0
    Preparing search index...

    Class Label

    ZPL Label class

    The Label class provides a fluent, immutable API for constructing ZPL (Zebra Programming Language) labels. It supports adding text, barcodes, boxes, images, and RFID fields, as well as parsing existing ZPL strings. Each method returns a new Label instance with the added elements, allowing for method chaining.

    Index

    Properties

    cfg: { dpi: DPI; units: Units }

    Public so advanced users (and your own components) can read cfg if needed

    fromZPL: (
        zpl: string | Uint8Array<ArrayBufferLike>,
        dpi?: DPI,
        units?: Units,
    ) => Label = Label.parse

    Back-compat alias if you like the old name

    Type Declaration

      • (zpl: string | Uint8Array<ArrayBufferLike>, dpi?: DPI, units?: Units): Label
      • Parse an existing ZPL string/bytes into a fluent Label instance

        Parameters

        • zpl: string | Uint8Array<ArrayBufferLike>
        • dpi: DPI = ...
        • units: Units = Units.Dot

        Returns Label

    Methods

    • Draw a box/line.

      Parameters

      Returns Label

      Border thickness is rounded to an integer with a minimum of 1. Corner radius is rounded and clamped between 0 and 8 to match ZPL limits.

    • Add a ZPL comment (^FX) - useful for debugging and documentation

      Parameters

      • text: string

      Returns Label

    • Set global barcode module settings (^BY) - affects all subsequent barcodes.

      Parameters

      • opts: { height?: number; moduleWidth?: number; wideToNarrowRatio?: number }

      Returns Label

      Module width, ratio, and height are rounded to integers with a minimum of 1 when provided.

    • Set global default font (^CF) - height/width rounded to ints with a minimum of 1.

      Parameters

      • opts: { family?: FontFamily; height?: number; width?: number }

      Returns Label

    • Add a text field.

      Parameters

      Returns Label

      Font height/width are rounded to integers with a minimum of 1. Wrap spacing and hanging indent are rounded to integers with a minimum of 0.

    • Emit the final ZPL string. Untouched tokens re-emit byte-identical.

      Returns string

    • Add metadata as ZPL comments (^FX) for debugging and traceability

      Parameters

      • meta: Record<string, string | number>

      Returns Label

    • Parse an existing ZPL string/bytes into a fluent Label instance

      Parameters

      • zpl: string | Uint8Array<ArrayBufferLike>
      • dpi: DPI = ...
      • units: Units = Units.Dot

      Returns Label