zplCore.comzplCore.com

Barcode

public sealed class Barcode

Stand-alone barcode generator (no ZPL needed): set Barcode.Symbology and Barcode.Code, then export as bitmap/PNG, vector PDF/SVG/EPS, or draw onto any SKCanvas.

Not thread-safe: a Barcode is a mutable settings object; use one instance per thread (instances on different threads are independent and deterministic). Invalid data throws ArgumentException, FormatException or NotSupportedException.

Online ausprobieren auf zplCloud.com: Barcode zu ZPL · QR-Code zu ZPL

Constructors

SignatureDescription
# Barcode()

Properties

PropertyTypeDescription
AddChecksum { get; set; }bool
Alignment { get; set; }BarcodeAlignmentPosition inside the target box (FitProportional / AutoSize).
AntiAlias { get; set; }boolAnti-aliased bars and modules (default off: crisp edges at whole pixels).
ArtBarImagePattern { get; set; }SKBitmapImage tiled as fill pattern of the bars / modules (instead of Barcode.ForeColor).
AztecErrorCorrection { get; set; }intAztec error correction in percent of the data (5..95, default 23).
AztecFormat { get; set; }AztecFormatAztec format (Auto = full range, as bwip-js; ZXing chooses when no other Aztec option is set).
AztecLayers { get; set; }intAztec layers (compact 1..4, full 1..32; 0 = automatic).
BackColor { get; set; }SKColor
BarArt { get; set; }BarArtMotif in the upper part of the bars of linear codes (EAN/UPC, Code 128, GS1-128, ITF …). Default none.
BarArtHeightPercent { get; set; }doublePart of the bar height the motif may use, 5–40 % (default 30): the rest stays plain bars.
BarArtImage { get; set; }SKBitmapSilhouette for BarArt.Image: dark, opaque pixels keep the bar, stretched over the motif band.
BarHeight { get; set; }doubleBar height of linear codes (2D codes ignore it; their modules are square).
BarWidth { get; set; }doubleNarrow bar / module width.
BarWidthReduction { get; set; }doubleBar width reduction (ink spread compensation) in Barcode.Unit: every dark bar/module gets narrower by this amount.
BarWidthReductionPercent { get; set; }doubleBar width reduction in percent of the module width (added to Barcode.BarWidthReduction).
BearerBarWidth { get; set; }double
BearerBars { get; set; }BearerBarStyleBearer bars (ITF-14 frame or horizontal rules).
BorderColor { get; set; }SKColor
BorderRadius { get; set; }doubleCorner radius of the border (and background) in Barcode.Unit.
BorderWidth { get; set; }doubleBorder line width in Barcode.Unit (0 = none).
ByteEncodingName { get; set; }stringCharacter encoding of the data bytes, e.g. "ISO-8859-5", "Shift_JIS", "UTF-8": the text is converted with that encoding and an ECI designator (Eci.FromEncodingName) is placed in front. Supported by QR Code, Aztec and MaxiCode; other symbologies with ECI support throw NotSupportedException.
CodabarStartChar { get; set; }char?Codabar start character A–D when the data has none (null = A).
CodabarStopChar { get; set; }char?Codabar stop character A–D when the data has none (null = A).
Code { get; set; }string
Code128Subset { get; set; }Code128SubsetCode 128 start code set: A/B/C start in that set and keep it unless the data contains ZPL invocation codes (>5, >6, >7); Auto = shortest encoding.
Code16KMode { get; set; }Code16KModeCode 16K start mode (initial code set); Auto = BWIPP's choice.
Code16KRows { get; set; }intMinimum number of Code 16K rows (2..16, 0 = automatic).
CodeEncoding { get; set; }CodeEncoding
CodeFormatPattern { get; set; }stringPattern applied to Barcode.Code before encoding (same syntax as Barcode.TextFormatPattern).
CompositeComponent { get; set; }CompositeComponentComposite component of the GS1 composite symbologies.
DataBarSegmentsPerRow { get; set; }int
DataMatrixDmre { get; set; }boolAllow the DMRE (ISO/IEC 21471) rectangles in the automatic rectangular size selection.
DataMatrixEncodation { get; set; }DataMatrixEncodationData Matrix encodation scheme. Non-Auto values use that scheme for every character it can represent (ASCII for the rest) instead of the look-ahead optimisation.
DataMatrixSize { get; set; }stringFixed Data Matrix size "RxC" (rows × columns), e.g. "24x24", "16x48"; DMRE sizes such as "8x48" are allowed. Null = smallest fitting.
DisplayChecksum { get; set; }boolShow computed check digits in the human readable text (default true).
DisplayStartStopChar { get; set; }bool?Show Code 39 '*' / Codabar start and stop characters (null = symbology default).
DotCodeAspectRatio { get; set; }doubleDotCode width:height ratio for the automatic size (0 = 1.5).
DotCodeColumns { get; set; }intDotCode columns (at least 5, 0 = automatic).
DotCodeRows { get; set; }intDotCode rows (at least 5, 0 = automatic). With both rows and columns their sum must be odd.
Dpi { get; set; }intResolution for raster output and unit conversion.
ErrorBehavior { get; set; }BarcodeErrorBehaviorError behaviour of the outputs (Barcode.Encode always throws).
FinderShape { get; set; }FinderShape
FontSize { get; set; }doubleFont size of the human readable text in points (0 = automatic, proportional to the module).
ForeColor { get; set; }SKColor
Gs1StrictValidation { get; set; }boolGS1-128: check AI values against the GS1 syntax rules (lint) instead of plain AI parsing.
GuardBarHeight { get; set; }double?EAN/UPC guard bar extension below the bars in Barcode.Unit (null = half the text height).
GuardBars { get; set; }boolExtend EAN/UPC guard bars into the text area.
HalftoneColor { get; set; }boolColour sub-modules from the image (PNG, SVG, PDF) instead of black-and-white error diffusion (thermal printers).
static HalftoneEnabled { get; set; }boolOpt-in for halftone QR (Barcode.HalftoneImage, HalftoneImageData) for the whole process. Default false: a halftone image is ignored, the code is printed as a plain QR Code and Barcode.CheckReadability reports AR011. Set it to true to render halftone QR codes; checking that this rendering method may be used in the countries where your labels are produced or used is your responsibility.
HalftoneImage { get; set; }SKBitmapHalftone QR: image worked into the code. Each module is split into 3 × 3 sub-modules; the centre sub-module and all finder, separator, timing, alignment, format and version modules keep the data, the other sub-modules follow the image (error diffusion to black and white, or the image colours with Barcode.HalftoneColor). QR codes only (Symbology.QrCode, Symbology.Gs1QrCode, Symbology.DinSpecQrCode); error correction is set to H, the module must be at least 3 pixels. Null = off. Only applied while Barcode.HalftoneEnabled is true.
HalftoneStrength { get; set; }doubleShare of the 8 outer sub-modules of each data module that follow the image, 0–1 (0 = plain code, 1 = all 8; the centre always keeps the data). Default 0.6 (5 of 8). Corners are given to the image first.
HanXinErrorCorrection { get; set; }intHan Xin error correction level 1..4 (L1..L4).
HanXinMode { get; set; }HanXinModeHan Xin: force numeric, text or binary encodation for the whole message.
HanXinVersion { get; set; }intHan Xin version 1..84 (0 = smallest fitting).
HumanReadableAlignment { get; set; }HumanReadableAlignment
HumanReadableText { get; set; }stringText instead of the encoded data (null = automatic, incl. check digits).
ItfHMarks { get; set; }boolITF-14: draw "H" marks in the quiet zones left and right of the symbol (inside the bearer frame).
JabCodeColors { get; set; }intJAB Code colours: 4, 8 (default), 16, 32, 64, 128 or 256.
JabCodeErrorCorrection { get; set; }intJAB Code error correction level 0..10 (default 6).
JabCodeMask { get; set; }intJAB Code mask 0..7 (-1 = best).
LightMarginIndicator { get; set; }boolEAN/UPC light margin indicators ('<' / '>') in the quiet zones (GS1 General Specifications).
LogoBackground { get; set; }boolDraw a plate in Barcode.BackColor behind the logo.
LogoImage { get; set; }SKBitmapLogo drawn in the center of 2D codes (QR: error correction is forced to H).
LogoOpacity { get; set; }doubleLogo opacity 0..1.
LogoPosition { get; set; }LogoPosition
LogoSizePercent { get; set; }doubleLogo width in percent of the symbol width (without quiet zone).
MagnificationFactor { get; set; }double?EAN/UPC magnification factor 0.8–2.0 (GS1 General Specifications): sets the module to 0.330 mm × factor and the bar height to 22.85 mm × factor (EAN-13, UPC-A, UPC-E and ISBN/ISSN/ISMN/JAN) or 18.23 mm × factor (EAN-8, JAN-8), overriding Barcode.BarWidth and Barcode.BarHeight. Null = off.
MaxiCodeMode { get; set; }int
MaxiCodePixelAligned { get; set; }boolMaxiCode: draw the hexagons without anti-aliasing with centres snapped to whole pixels (crisp thermal output).
MicroPdf417Columns { get; set; }intMicroPDF417 columns (1..4, 0 = automatic).
MicroPdf417Rows { get; set; }intMicroPDF417 rows (per the ISO size table, 0 = automatic).
MicroQrVersion { get; set; }intMicro QR version 1..4 (M1..M4), 0 = smallest fitting.
ModuleShape { get; set; }ModuleShape
MsiChecksum { get; set; }MsiChecksum?MSI check digits (null = mod 10, the encoder default).
Padding { get; set; }BarcodePaddingMargin around the barcode (outside the quiet zone, inside the border) in Barcode.Unit.
Pdf417AspectRatio { get; set; }doublePDF417 width:height ratio of the symbol (without quiet zone) used to choose the column count when Barcode.Pdf417Columns is 0 (0 = BWIPP default).
Pdf417Columns { get; set; }int
Pdf417Compaction { get; set; }Pdf417CompactionPDF417 compaction: Auto (text/numeric/byte optimisation), all Numeric, or all Binary (byte).
Pdf417Rows { get; set; }intPDF417 rows (3..90, 0 = automatic).
Pdf417SecurityLevel { get; set; }int
PharmacodeSpacing { get; set; }intPharmacode space between bars in modules (default 2).
PharmacodeThickBar { get; set; }intPharmacode thick bar width in modules (default 3).
PharmacodeThinBar { get; set; }intPharmacode thin bar width in modules (default 1).
PostalBarSpacing { get; set; }doublePostal codes: gap between bars in modules (default 1.5).
PostalShortBarRatio { get; set; }doublePOSTNET/PLANET short bar height as fraction of Barcode.BarHeight (default 0.4).
PostalTrackerRatio { get; set; }double4-state postal codes: tracker height as fraction of Barcode.BarHeight (default 1/3).
ProcessTilde { get; set; }boolTilde escapes: ~~ tilde, ~dNNN byte, ~1 FNC1 (GS1 when first, else GS), ~2IICC structured append (index, count, 2 digits each), ~eNNNNNN / ~5NNNNNN ECI.
QrEncodingMode { get; set; }QrEncodingModeQR Code data mode: Auto (BWIPP segmentation) or one segment in the given mode. Kanji encodes the text as Shift JIS double-byte characters.
QrErrorCorrection { get; set; }char
QrMask { get; set; }intQR mask pattern 0–7 (-1 = automatic).
QrVersion { get; set; }intQR version 1–40 (0 = smallest fitting).
QuietZone { get; set; }int?Quiet zone in modules on every side (null: 10 for linear codes and Codablock F, 4 for 2D and the other stacked codes; Code 16K and Code 49 additionally carry their 10X/1X quiet zones inside the symbol).
ReadabilityMinContrast { get; set; }doubleSmallest contrast between Barcode.ForeColor and Barcode.BackColor (luminance difference 0–1) below which Barcode.CheckReadability reports a finding. Default 0.4 (ISO symbol contrast grade C).
ReadabilityMinModulePixels { get; set; }doubleSmallest module size in pixels for shaped modules below which Barcode.CheckReadability reports a finding. Default 4.
RectMicroQrVersion { get; set; }stringrMQR version, e.g. "R7x43" … "R17x139"; null = smallest area.
RightToLeft { get; set; }boolDraw the human readable text right to left (character order reversed).
Rotation { get; set; }intRotation in degrees (0, 90, 180, 270).
Size { get; }SKSizeSize of the output in pixels before rotation: the natural barcode plus Barcode.Padding and border, or the target box of Barcode.Sizing.
Sizing { get; set; }BarcodeSizingSizing mode; needs Barcode.TargetWidth and Barcode.TargetHeight (in Barcode.Unit, final orientation).
StructuredAppendInfo { get; set; }StructuredAppendInfoStructured append for QR, Data Matrix, Aztec, MaxiCode and PDF417 (null = none).
Supplement { get; set; }stringEAN/UPC 2- or 5-digit supplement drawn right of the main symbol.
SupplementSpacing { get; set; }intEAN/UPC supplement gap in modules (default 9).
SupplementTopMargin { get; set; }double?EAN/UPC supplement: distance from the top of the main bars to the top of the supplement bars (in Barcode.Unit; null = the height of the text line).
Symbology { get; set; }Symbology
TargetHeight { get; set; }doubleOutput height for Barcode.Sizing (in Barcode.Unit).
TargetWidth { get; set; }doubleOutput width for Barcode.Sizing (in Barcode.Unit).
TextColor { get; set; }SKColor
TextFormatPattern { get; set; }stringFormat for the human readable text: a composite format such as "{0:### ### ###}" (applied to the numeric value when the text is numeric) or a mask where A a 9 # X x * ? take the next character and everything else is literal, e.g. "AAA-999".
TextPosition { get; set; }BarcodeTextPosition
TextStrikeout { get; set; }bool
TextUnderline { get; set; }bool
Tlc39Gap { get; set; }intTLC39: gap between the MicroPDF417 and the Code 39 part in modules (ZPL ^BT uses 2).
Tlc39MicroPdfRowHeight { get; set; }intTLC39: height of one MicroPDF417 row in modules (ZPL ^BT h2; default 2).
Typeface { get; set; }SKTypeface
UltracodeErrorCorrection { get; set; }intUltracode error correction level 1..5 (EC1..EC5, default 2).
Unit { get; set; }BarcodeUnitUnit of Barcode.BarWidth, Barcode.BarHeight, Barcode.BearerBarWidth.
UseQuietZoneForText { get; set; }boolLinear codes: the human readable text uses the quiet zone below (or above) the bars instead of adding height.
VerifyReadability { get; set; }boolDecode artistic codes (module/finder shapes, logo, halftone image, bar motif) after rendering at Barcode.Dpi with zxing-cpp and ZXing.Net. A halftone image or bar motif that does not read is weakened step by step (down to the plain code). Results are cached per content and settings. Default true.
WideRatio { get; set; }doubleWide-to-narrow ratio for two-width codes (2.0–3.0).

Methods

Method SignatureReturnsDescription
# CheckReadability()BarcodeReadabilityDecodes the rendered symbol (rotation 0, without the human-readable text, camera-blurred) at Barcode.Dpi with zxing-cpp and ZXing.Net and compares the data; zxing-cpp decides (ZXing.Net where it is not available). A halftone image or bar motif that does not read is weakened in steps (75 %, 50 %, 25 %, off); the result names what is printed. Cached per content and settings.
static # ClearReadabilityCache()voidClears the readability cache (tests, memory pressure).
# Draw(SKCanvas canvas, float x = 0, float y = 0)voidDraws the barcode with vector primitives onto any canvas (raster, PDF, SVG).
# Encode()BarcodeMatrixEncodes Barcode.Code to modules.
# IsCodeValid()boolTrue when Barcode.Code can be encoded with the current settings.
# IsCodeValid(out string error)boolTrue when Barcode.Code can be encoded; otherwise error describes why.
# StructuredAppend(int index, int count, int parity = -1, string? fileId = default)BarcodeSets structured append: symbol index (1-based) of count.
# ToBitmap()SKBitmap
# ToEps()stringEncapsulated PostScript (vector bars, text in Courier).
# ToEps(EpsColorMode colorMode)stringEncapsulated PostScript in the given color model (RGB, CMYK or grayscale operators).
# ToHtmlImgTag(HtmlImageFormat format = HtmlImageFormat.Png, string? alt = default)stringHTML <img> tag with the barcode as data URI.
# ToJpeg(int quality = 95)byte[]
# ToPcl()byte[]PCL5 raster page at Barcode.Dpi.
# ToPcx()byte[]1-bit PCX at Barcode.Dpi.
# ToPdf()byte[]Vector PDF with the physical size of the barcode.
# ToPng()byte[]
# ToSvg()stringVector SVG.
# ToTiff(TiffCompression compression = TiffCompression.PackBits)byte[]1-bit TIFF (via RasterExport) at Barcode.Dpi.
# ToWebp(int quality = 95)byte[]
# ToZplGraphic(int x = 0, int y = 0)stringThe barcode as ZPL graphic (^GFA) at the given position, e.g. for symbologies without a ZPL command.