zplCore.comzplCore.com
class17 members

ZplRenderer

public sealed class ZplRenderer

Virtual 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.

Online ausprobieren auf zplCloud.com: ZPL zu PDF · ZPL zu PNG · ZPL zu SVG

Constructors

SignatureDescription
# ZplRenderer(ZplRenderSettings? settings = default)

Properties

PropertyTypeDescription
LastCutPlan { get; }ZplCutPlanCut 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; }ZplPrintModePrint 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; }ZplPrintModePrint mode saved with ^JUS (restored by ~JR / ZplRenderer.Reset).
Settings { get; }ZplRenderSettings
Store { get; init; }ZplResourceStoreEmulated printer memory. Can be shared between renderers.

Methods

Method SignatureReturnsDescription
# 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()voidClears printer memory and label setup (power-on reset).

Events

EventHandler TypeDescription
LabelRenderedEventHandler<ZplLabelRenderedEventArgs>Raised for every rendered label (after encoding).
PrinterControlEventHandler<ZplPrinterControlEventArgs>Raised for printer control commands that don't affect the image (media, darkness, status ~HS, calibration, ...). Set ZplPrinterControlEventArgs.Response to answer host queries.