QRCodeRenderer Class

Provides methods to render a QR code as a vector scene or as an SVG document.

public static class QRCodeRenderer

Remarks

The scene is what every renderer draws: QRCodeRenderer.ToSvg writes it as SVG, Meziantou.Framework.Imaging.Barcodes draws it as an image (PNG, WebP, JPEG...), and Meziantou.Framework.Pdf.VectorGraphics as a PDF.

Methods

NameDescription
CreateScene(QRCode, QRCodeRenderOptions?)Creates the scene of the QR code: the quiet zone, the modules and the logo, on the modules it clears.
ToSvg(QRCode, QRCodeRenderOptions?, SvgRenderOptions?)Renders the QR code as an SVG document.

CreateScene(QRCode, QRCodeRenderOptions?)

QRCodeRenderer.cs

Creates the scene of the QR code: the quiet zone, the modules and the logo, on the modules it clears.

public static Scene CreateScene(this QRCode qrCode, QRCodeRenderOptions? options = null)

Parameters

qrCode QRCode
The QR code to render.
options QRCodeRenderOptions?
The rendering options, or null for the defaults.

Returns

Scene The scene of the QR code, as large as the QR code and its quiet zone.

Exceptions

ArgumentNullException
qrCode or QRCodeRenderOptions.DarkPaint is null.
ArgumentOutOfRangeException
An option is out of range, the dimensions of the drawing are too large, or the QR code cannot lose the modules cleared under the logo (BarcodeLogo.ClearModules).
ArgumentException
The data of the logo is not a PNG, JPEG, GIF or WebP file.

ToSvg(QRCode, QRCodeRenderOptions?, SvgRenderOptions?)

QRCodeRenderer.cs

Renders the QR code as an SVG document.

public static string ToSvg(this QRCode qrCode, QRCodeRenderOptions? options = null, SvgRenderOptions? svgOptions = null)

Parameters

qrCode QRCode
The QR code to render.
options QRCodeRenderOptions?
The rendering options, or null for the defaults.
svgOptions SvgRenderOptions?
The options of the SVG writer, or null for the defaults.

Returns

string The SVG document, without an XML declaration.

Exceptions

ArgumentNullException
qrCode or QRCodeRenderOptions.DarkPaint is null.
ArgumentOutOfRangeException
An option is out of range, the dimensions of the drawing are too large, or the QR code cannot lose the modules cleared under the logo (BarcodeLogo.ClearModules).
ArgumentException
The data of the logo is not a PNG, JPEG, GIF or WebP file.