QRCodeRenderer Class
Provides methods to render a QR code as a vector scene or as an SVG document.
public static class QRCodeRendererRemarks
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
| Name | Description |
|---|---|
| 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.csCreates 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
qrCodeQRCode- The QR code to render.
optionsQRCodeRenderOptions?- The rendering options, or
nullfor the defaults.
Returns
Scene The scene of the QR code, as large as the QR code and its quiet zone.
Exceptions
ArgumentNullExceptionqrCodeorQRCodeRenderOptions.DarkPaintisnull.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.csRenders the QR code as an SVG document.
public static string ToSvg(this QRCode qrCode, QRCodeRenderOptions? options = null, SvgRenderOptions? svgOptions = null)Parameters
qrCodeQRCode- The QR code to render.
optionsQRCodeRenderOptions?- The rendering options, or
nullfor the defaults. svgOptionsSvgRenderOptions?- The options of the SVG writer, or
nullfor the defaults.
Returns
string The SVG document, without an XML declaration.
Exceptions
ArgumentNullExceptionqrCodeorQRCodeRenderOptions.DarkPaintisnull.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.