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 Barcode2DRendererRemarks
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
| Name | Description |
|---|---|
| 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.csCreates the scene of the barcode: the quiet zone and the modules.
public static Scene CreateScene(this Barcode2D barcode, Barcode2DRenderOptions? options = null)Parameters
barcodeBarcode2D- The barcode to render.
optionsBarcode2DRenderOptions?- The rendering options, or
nullfor the defaults.
Returns
Scene The scene of the barcode, as large as the symbol and its quiet zone.
Exceptions
ArgumentNullExceptionbarcodeorBarcode2DRenderOptions.DarkPaintisnull.ArgumentOutOfRangeException- An option is out of range, or the dimensions of the drawing are too large.
ToSvg(Barcode2D, Barcode2DRenderOptions?, SvgRenderOptions?)
Barcode2DRenderer.csRenders the barcode as an SVG document.
public static string ToSvg(this Barcode2D barcode, Barcode2DRenderOptions? options = null, SvgRenderOptions? svgOptions = null)Parameters
barcodeBarcode2D- The barcode to render.
optionsBarcode2DRenderOptions?- 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
ArgumentNullExceptionbarcodeorBarcode2DRenderOptions.DarkPaintisnull.ArgumentOutOfRangeException- An option is out of range, or the dimensions of the drawing are too large.