Barcode2DRenderer Class

Provides methods to render a two-dimensional barcode (Data Matrix, PDF417, Aztec) as a vector scene or as an SVG document.

public static class Barcode2DRenderer

Remarks

The scene is what every renderer draws: Barcode2DRenderer.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(Barcode2D, Barcode2DRenderOptions?)Creates the scene of the barcode: the quiet zone and the modules.
ToSvg(Barcode2D, Barcode2DRenderOptions?, SvgRenderOptions?)Renders the barcode as an SVG document.

CreateScene(Barcode2D, Barcode2DRenderOptions?)

Barcode2DRenderer.cs

Creates the scene of the barcode: the quiet zone and the modules.

public static Scene CreateScene(this Barcode2D barcode, Barcode2DRenderOptions? options = null)

Parameters

barcode Barcode2D
The barcode to render.
options Barcode2DRenderOptions?
The rendering options, or null for the defaults.

Returns

Scene The scene of the barcode, as large as the symbol and its quiet zone.

Exceptions

ArgumentNullException
barcode or Barcode2DRenderOptions.DarkPaint is null.
ArgumentOutOfRangeException
An option is out of range, or the dimensions of the drawing are too large.

ToSvg(Barcode2D, Barcode2DRenderOptions?, SvgRenderOptions?)

Barcode2DRenderer.cs

Renders the barcode as an SVG document.

public static string ToSvg(this Barcode2D barcode, Barcode2DRenderOptions? options = null, SvgRenderOptions? svgOptions = null)

Parameters

barcode Barcode2D
The barcode to render.
options Barcode2DRenderOptions?
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
barcode or Barcode2DRenderOptions.DarkPaint is null.
ArgumentOutOfRangeException
An option is out of range, or the dimensions of the drawing are too large.