zplCore.comzplCore.com

SvgImage

public static class SvgImage

Small SVG rasterizer for icons and logos on labels (no dependency beyond SkiaSharp, NativeAOT-safe): path, circle, rect (also rounded), ellipse, line, polyline, polygon, text and nested g groups with inherited fill; fill, stroke, stroke-width and the viewBox. No transforms, CSS, gradients, use or masks – for complete SVG to native ZPL use ZplCore.VectorLift. Rendered anti-aliased on white; on a label only the dark parts print (white is transparent).

Methods

Method SignatureReturnsDescription
static # IsSvg(ReadOnlySpan<byte> data)boolTrue when the bytes are an SVG document (XML whose root is svg).
static # Render(string svg, int width, int height, bool keepAspectRatio = true)SKBitmapRenders the SVG into width × height pixels, anti-aliased on white: scaled uniformly and centred (preserveAspectRatio="xMidYMid meet"), or stretched to fill when keepAspectRatio is false.
static # ToGraphicField(string svg, int heightDots, int rotation = 0, bool trim = true)(string, int, int)SVG → ^GFA (ACS compressed, threshold 128): rendered heightDots high with the width of the viewBox aspect ratio, turned by rotation degrees and – with trim – cut to the drawn content. Returns the command without ^FO/^FS and the graphic size in dots. Throws InvalidDataException: The SVG draws nothing.
static # ViewBox(string svg)(double, double, double, double)The viewBox (x, y, width, height); without one width/height, else 0 0 100 100.