BarcodeConsoleRenderer Class

Provides methods to render a linear barcode using Unicode block characters.

public static class BarcodeConsoleRenderer

Methods

NameDescription
ToConsoleString(Barcode, ConsoleRenderOptions?)Renders the barcode as a string using Unicode block characters.
WriteTo(Barcode, TextWriter, ConsoleRenderOptions?)Renders the barcode to a TextWriter using Unicode block characters.
WriteToConsole(Barcode, ConsoleRenderOptions?)Renders the barcode to Console.Out.

ToConsoleString(Barcode, ConsoleRenderOptions?)

BarcodeConsoleRenderer.cs

Renders the barcode as a string using Unicode block characters.

public static string ToConsoleString(this Barcode barcode, ConsoleRenderOptions? options = null)

Parameters

barcode Barcode
The barcode to render.
options ConsoleRenderOptions?
The rendering options, or null for the defaults.

Returns

string The lines of the barcode, without trailing spaces and without a final new line.

Exceptions

ArgumentNullException
barcode is null.
ArgumentOutOfRangeException
An option is out of range, or the text is too large for a string.

Remarks

Each module is ConsoleRenderOptions.ModuleWidth characters wide. The bars of a barcode that is not stacked are ConsoleRenderOptions.BarHeight lines high; the rows of a stacked barcode are drawn as the rows of a two-dimensional symbol, two per line. The quiet zone is on the left and right sides only.

WriteTo(Barcode, TextWriter, ConsoleRenderOptions?)

BarcodeConsoleRenderer.cs

Renders the barcode to a TextWriter using Unicode block characters.

public static void WriteTo(this Barcode barcode, TextWriter writer, ConsoleRenderOptions? options = null)

Parameters

barcode Barcode
The barcode to render.
writer TextWriter
The destination.
options ConsoleRenderOptions?
The rendering options, or null for the defaults.

Exceptions

ArgumentNullException
barcode or writer is null.
ArgumentOutOfRangeException
An option is out of range, or the text is too large for a string.

WriteToConsole(Barcode, ConsoleRenderOptions?)

BarcodeConsoleRenderer.cs

Renders the barcode to Console.Out.

public static void WriteToConsole(this Barcode barcode, ConsoleRenderOptions? options = null)

Parameters

barcode Barcode
The barcode to render.
options ConsoleRenderOptions?
The rendering options, or null for the defaults.

Exceptions

ArgumentNullException
barcode is null.
ArgumentOutOfRangeException
An option is out of range, or the text is too large for a string.