escpos-ts API - v1.0.0
    Preparing search index...

    Class QrHelper

    Helper that constructs the complete ESC/POS byte sequence for a native (printer-side) QR code. The returned Buffer must be written to the printer verbatim — no further transformation is needed.

    The sequence consists of five sub-commands in order:

    1. Set QR model (fn = 0x41)
    2. Set module size (fn = 0x43)
    3. Set error correction (fn = 0x45)
    4. Store data (fn = 0x50)
    5. Print stored symbol (fn = 0x51)
    import { QrHelper, QrOptions } from './qr/QrHelper';
    import { QR_ECLEVEL_M, QR_MODEL_2 } from './constants';

    const bytes = QrHelper.generate('https://example.com', {
    model: QR_MODEL_2,
    size: 4,
    eclevel: QR_ECLEVEL_M,
    });
    printer._raw(bytes);

    1.0.0

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Generate the full ESC/POS QR code byte sequence for the given text.

      Parameters

      • text: string

        The string to encode. Encoded as UTF-8.

      • options: QrHelperOptions = {}

        Optional QR parameters (model, size, error correction).

      Returns Buffer

      A Buffer containing the concatenated ESC/POS commands.

      If text is empty.

      If size is outside the 1–16 range.

      If model or eclevel is not a recognised constant.

      1.0.0