ZplRenderer
public sealed class ZplRendererVirtual ZPL printer: renders ZPL II to PNG/JPEG/WebP/BMP/PDF/GRF. Keeps printer memory (graphics, formats, fonts, label setup) between calls, like a real printer.
Thread safety: a
ZplRenderer instance is not thread-safe (it keeps printer state such as ^LH/^PW/^MC between calls); use one instance per thread or synchronise access. Different instances may render concurrently and produce output identical to single-threaded rendering. A ZplResourceStore may be shared between instances (it is thread-safe); ZplRenderer.Settings must not be modified while rendering. Untrusted input is bounded by ZplRenderSettings.MaxLabelDots, ZplRenderSettings.MaxQuantity, ZplRenderSettings.MaxLabels, ZplRenderSettings.MaxGraphicBytes and ZplRenderSettings.MaxFieldDataLength. See THREADING.md.Try it online on zplCloud.com: ZPL to PDF · ZPL to PNG · ZPL to SVG
Constructors
| Signature | Description |
|---|---|
# ZplRenderer(ZplRenderSettings? settings = default) |
Properties
| Property | Type | Description |
|---|---|---|
LastCutPlan { get; } | ZplCutPlan | Cut plan of the last ZplRenderer.Render / ZplRenderer.ProcessCommands / ZplRenderer.RenderSvg call: where a Zebra printer with cutter cuts (^MM, ^PQ, ^XB, ^CN, ^KV, ^JU, ~JK). Always computed (no effect on the output); set ZplRenderSettings.CutMarks to also draw the cuts into previews. |
LastElements { get; } | IReadOnlyList<IReadOnlyList<ZplRenderedElement>> | Elements of the last ZplRenderer.ProcessCommands call (if ZplRenderSettings.TraceElements). |
LastRfidCommands { get; } | IReadOnlyList<IReadOnlyList<ZplRfidCommand>> | RFID commands of each label of the last ZplRenderer.Render / ZplRenderer.ProcessCommands call (see ZplRenderResult.RfidCommands). |
PrintMode { get; } | ZplPrintMode | Print mode (^MM) currently in effect; persists across formats like on a printer. |
Responses { get; } | List<string> | Responses produced for host queries (~HS, ~HI ...) during the last call. |
SavedPrintMode { get; } | ZplPrintMode | Print mode saved with ^JUS (restored by ~JR / ZplRenderer.Reset). |
Settings { get; } | ZplRenderSettings | |
Store { get; init; } | ZplResourceStore | Emulated printer memory. Can be shared between renderers. |
Methods
| Method Signature | Returns | Description |
|---|---|---|
# ProcessCommands(string zpl) | List<byte[]> | Renders ZPL and returns one encoded image per printed label (PDF: one document with all pages). |
# ProcessCommands(byte[] zpl, Encoding? encoding = default) | List<byte[]> | Raw ZPL bytes, read like a Zebra printer (ZplTextEncoding: the code page of the active ^CI, power-up ZplRenderSettings.DefaultCodePage); a byte order mark or valid UTF-8 text is read as Unicode. |
# ProcessFile(string path) | List<byte[]> | |
# Render(string zpl) | List<ZplRenderResult> | Renders ZPL to bitmaps. The caller owns (and must dispose) the bitmaps. |
# RenderSvg(string zpl) | List<string> | Renders all labels as vector SVG documents (independent of ZplRenderSettings.OutputFormat; the other settings such as ZplRenderSettings.SvgSelectableText and colours apply). Shapes, barcodes and text (glyph outlines) are vector paths; each field is a <g> with data-cmd/data-offset/data-length. |
# Reset() | void | Clears printer memory and label setup (power-on reset). |
Events
| Event | Handler Type | Description |
|---|---|---|
LabelRendered | EventHandler<ZplLabelRenderedEventArgs> | Raised for every rendered label (after encoding). |
PrinterControl | EventHandler<ZplPrinterControlEventArgs> | Raised for printer control commands that don't affect the image (media, darkness, status ~HS, calibration, ...). Set ZplPrinterControlEventArgs.Response to answer host queries. |

