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.
Buffer
The sequence consists of five sub-commands in order:
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); Copy
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
Static
Generate the full ESC/POS QR code byte sequence for the given text.
The string to encode. Encoded as UTF-8.
Optional QR parameters (model, size, error correction).
A Buffer containing the concatenated ESC/POS commands.
If text is empty.
text
If size is outside the 1–16 range.
size
If model or eclevel is not a recognised constant.
model
eclevel
Helper that constructs the complete ESC/POS byte sequence for a native (printer-side) QR code. The returned
Buffermust be written to the printer verbatim — no further transformation is needed.The sequence consists of five sub-commands in order:
Example
Since
1.0.0