OnBarcode C# Barcode library provide detailed options to create and customize QR Code, 2d and linear barcode symbologies.
You can find all the barcode customization properties in the following C# classes.
- OnBarcode.Barcode.Linear (for 1d barcode generation, such as Code 128, Code 39, UPC/EAN)
- OnBarcode.Barcode.QRCode (for QR Code generation)
- OnBarcode.Barcode.DataMatrix (for Data Matrix generation)
- OnBarcode.Barcode.PDF417 (for PDF-417 generation)
- OnBarcode.Barcode.MicroPDF417 (for Micro PDF-417 generation)
- OnBarcode.Barcode.MicroQRCode (for Micro QR Code generation)
Complete List of Barcode Properties
| Category | Properties | Value | Comments |
| Basic | Property: Data
URL: DATA |
Type: string
Default: "12345" |
Barcode value to encode
Code 128 Valid Data Char Set:
|
|
Property: Type
URL: TYPE |
Type: BarcodeType
Default: CODE128 (7) |
Linear barcode symbology type.
Complete list of supported linear barcode formats: public enum BarcodeType { CODABAR, CODE11, CODE2OF5, INTERLEAVED25, CODE39, CODE39EX, CODE93, CODE128, CODE128A, CODE128B, CODE128C, EAN128, EAN8, EAN8_2, EAN8_5, EAN13, EAN13_2, EAN13_5, ISBN, ISBN_2, ISBN_5, ISSN, ISSN_2, ISSN_5, ITF14, IDENTCODE, LEITCODE, MSI, MSI10, MSI11, MSI1010, MSI1110, ONECODE, PLANET, POSTNET, RM4SCC, UPCA, UPCA_2, UPCA_5, UPCE, UPCE_2, UPCE_5, RSS14, RSS14STACKED, RSS14STACKEDOMNI, RSSLIMITED, RSSEXPANDED, RSSEXPANDEDSTACKED, COMPOSITE_CCA, COMPOSITE_CCB, COMPOSITE_CCC } |
| Data Encoding Related |
Property: AddCheckSum
URL: ADD-CHECK-SUM |
Type: bool
Default: false |
For linear / 1D barcode formats only. The property is applicable for those formats whose check sum digit is optional.
Some linear barcode formats do not support this property. Please check your target barcode format document. |
| Property: ProcessTilde
URL: PROCESS-TILDE |
Type: bool
Default: false |
Set the ProcessTilde property to true, if you want use the tilde character "~"
to specify special characters in the input data.
|
| Barcode Size Related |
Property: AutoResize
URL: AUTO-RESIZE |
Type: bool
Default: true |
Auto resize the generated barcode image.
If the property value is true, the generated barcode image width and height are decided by the property BarcodeWidth and BarcodeHeight. And the property X and Y will be ignored. The barcode library will calculate and set the maximum value of X and Y. |
| Property: AutoResizeBarcodeText |
Type: bool
Default: true |
The property will only be applicable when AutoResize is true.
If the property AutoResizeBarcodeText is true, then the barcode text label below barcode will be auto resized. |
|
| Property: AutoResizePaddingTransparent |
Type: bool
Default: true |
The property will only be applicable when AutoResize is true.
If the property AutoResizePaddingTransparent is true, then the padding area around the barcode will be in transparent color. If it is false, the padding area around the barcode will be the same color as BackColor |
|
| Property: IsMinQuietZoneApplied |
Type: bool
Default: true |
Some barcode specification, (such as QR Code) requires minimum quiet zone. You can turn it off by setting the property to false. | |
|
Property: BarAlignment
URL: BAR-ALIGNMENT |
Type: int
Default: 1 (center) |
Barcode horizontal alignment inside the image. 0: left, 1: center, 2: right. | |
|
Property: UOM
URL: UOM |
Type: UnitOfMeasure
Default: PIXEL (0) |
Unit of meature for all size related settings in the library.
Valid values:
|
|
|
Property: X
URL: X |
Type: float
Default: 1 |
Width of barcode bar module (narrow bar), default is 1 pixel | |
|
Property: Y
URL: Y |
Type: float
Default: 60 |
Height of barcode bar module, default is 60 pixel | |
|
Property: BarcodeWidth
URL: BARCODE-WIDTH |
Type: float
Default: 0 |
Barcode image width.
If barcodeWidth setting is smaller than the barcode required minimum width, the library will automatically reset to barcode minimum width. |
|
|
Property: BarcodeHeight
URL: BARCODE-HEIGHT |
Type: float
Default: 0 |
Barcode image height.
If barcodeHeight setting is smaller than the barcode required minimum height, the library will automatically reset to barcode minimum height. |
|
|
Property: LeftMargin
URL: LEFT-MARGIN |
Type: float
Default: 0 |
Barcode image left margin size. | |
|
Property: RightMargin
URL: RIGHT-MARGIN |
Type: float
Default: 0 |
Barcode image right margin size. | |
|
Property: TopMargin
URL: TOP-MARGIN |
Type: float
Default: 0 |
Barcode image top margin size. | |
|
Property: BottomMargin
URL: BOTTOM-MARGIN |
Type: float
Default: 0 |
Barcode image bottom margin size. | |
|
Property: Resolution
URL: RESOLUTION |
Type: int
Default: 72 |
Barcode image resolution in DPI (Dots per inch). | |
|
Property: Rotate
URL: ROTATE |
Type: Rotate
Default: Rotate0 (0) |
Valid values:
|
| Barcode Colors |
Property: BackColor
URL: BACK-COLOR |
Type: Color
Default: white |
Barcode image background color.
To create barcode image with transparent background in C#, you can set the property BackColor to Color.Transparent. C# sample code: Linear barcode = new Linear(); barcode.BackColor = Color.Transparent; |
|
Property: ForeColor
URL: FORE-COLOR |
Type: Color
Default: black |
Barcode image foreground color | |
| Property: UseCMYKInEPS |
Type: bool
Default: false |
For EPS file only.
If true, the barcode library will print barcode in EPS file with CMYK color converted from RGB color in BackColor and ForeColor. |
| Font Style |
Property: ShowText
URL: SHOW-TEXT |
Type: bool
Default: true |
If true, display barcode data text under the barcode, otherwise do not display. |
| Property: ShowCheckSumChar |
Type: bool
Default: true |
If true, display the barcode checksum digit character in the barcode text. | |
|
Property: TextFont
URL: TEXT-FONT |
Type: Font
Default: new Font("Arial", 9f, FontStyle.Regular) |
Barcode text font style.
In ASP.NET web streaming, using the url paramter in the following format: &TEXT-FONT=Arial|9|regular |
|
|
Property: TextMargin
URL: TEXT-MARGIN |
Type: float
Default: 6 |
Space between barcode and barcode data text, default is 6 pixel | |
|
Property: TextColor
URL: TEXT-COLOR |
Type: Color
Default: black |
Barcode text color | |
| Property: TopTextColor |
Type: Color
Default: Color.Black |
For ISBN, ISSN only, the text color displayed on the top of the barcode. |
| Image Format |
Property: OutputFileFormat
URL: FILE-FORMAT |
Type: FileFormat (enum)
Default: PNG |
Barcode raster and vector image encoding type.
Supporting formats:
For System.Drawing version: BMP/GIF/JPG/PNG/TIF/EPS/SVG For SkiaSharp version: JPG/PNG/WEBP/EPS/SVG You can draw and print barcode in Vector image file. View details here: How to create barcode in vector image, SVG or EPS using C#? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| In WebStream query string, please use int value for Enums, "true" and "false" for bool. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
QR Code
| Category | Properties | Value | Comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Basic | Property: Data
URL: DATA |
Type: string
Default: "QRCode" |
Barcode value to encode
QRCode Valid Data Char Set:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| QRCode Special |
Property: ProcessTilde
URL: PROCESS-TILDE |
Type: bool
Default: true |
Set the ProcessTilde property to true, if you want use the tilde character "~" to specify special characters in the input data. Default is true.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: DataMode
URL: DATA-MODE |
Type: QRCodeDataMode
Default: QRCodeDataMode.Auto (0) |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: ECL
URL: ECL |
Type: QRCodeECL
Default: QRCodeECL.L (0) |
QRCode Error Correction Level. Default is QRCodeECL.L (0).
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Property: FNC1
URL: FNC1 |
Type: FNC1
Default: FNC1. FNC1_NONE (0) |
To encode GS1 compatible QR-Code barcode, you need set FNC1 value to FNC1.FNC1_1ST_POS (1). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: StructuredAppend
URL: STRUCTURED-APPEND |
Type: bool
Default: false |
Set StructuredAppend property to true, then Structured Append is enabled. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: SymbolCount
URL: SYMBOL-COUNT |
Type: int
Default: 0 |
the number of total symbols which make the sequence. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: SymbolIndex
URL: SYMBOL-INDEX |
Type: int
Default: 0 |
the position of current symbol in the secuence (Start with 0). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Parity
URL: PARITY |
Type: int
Default: 0 |
- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Version
URL: VERSION |
Type: QRCodeVersion
Default: QRCodeVersion.V1 (1). |
Valid values are from V1 to V40. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Logo | Type: System.Drawing.Bitmap
Default: null |
A Bitmap object containing logo image | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: LogoActualSize | Type: System.Drawing.SizeF | Logo displayed area on QR Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Data Matrix
| Category | Properties | Value | Comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Basic | Property: Data
URL: DATA |
Type: string
Default: "DataMatrix" |
Barcode value to encode
Data Matrix Valid Data Char Set:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Data Matrix Special |
Property: ProcessTilde
URL: PROCESS-TILDE |
Type: bool
Default: true |
Set the ProcessTilde property to true, if you want use the tilde character "~" to specify special characters in the input data. Default is true.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Property: DataMode
URL: DATA-MODE |
Type: DataMatrixDataMode
Default: DataMatrixDataMode. ASCII (1) |
Data Matrix data encoding mode.
Valid values are:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Property: FormatMode
URL: FORMAT-MODE |
Type: DataMatrixFormatMode
Default: DataMatrixFormatMode. Format_10X10 (0) |
Default is DataMatrixFormatMode.Format_10X10 (0). Specifies the Data Matrix Format to use on that symbology. Valid values see enum DataMatrixFormatMode.Format_*X*; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Property: FNC1
URL: FNC1 |
Type: FNC1
Default: FNC1. FNC1_NONE (0) |
To encode GS1 compatible Data Matrix barcode, you need set FNC1 value to FNC1.FNC1_1ST_POS (1). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Property: StructuredAppend
URL: STRUCTURED-APPEND |
Type: bool
Default: false |
Set StructuredAppend property to true, then Structured Append is enabled. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Property: SymbolCount
URL: SYMBOLE-COUNT |
Type: int
Default: 0 |
Set SymbolCount property to the number of total symbols which make the sequence. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Property: SymbolIndex
URL: SYMBOL-INDEX |
Type: int
Default: 0 |
Set SymbolIndex property to the position of current symbol in the secuence (Start with 0). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Property: FileId
URL: FILE-ID |
Type: int
Default: 0 |
Set FileId property to be identified to the same file. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PDF-417
| Category | Properties | Value | Comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Basic | Property: Data
URL: DATA |
Type: string
Default: "PDF417" |
Barcode value to encode
PDF-417 Valid Data Char Set:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PDF 417 Special |
Property: ProcessTilde
URL: PROCESS-TILDE |
Type: bool
Default: true |
Set the ProcessTilde property to true, if you want use the tilde character "~" to specify special characters in the input data. Default is true.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: DataMode
URL: DATA-MODE |
Type: PDF417DataMode
Default: PDF417DataMode.Text (1) |
valid values:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: ECL
URL: ECL |
Type: PDF417ECL
Default: PDF417ECL.Level_2 (2) |
Error correction level, values are from PDF417ECL.Level_0 to PDF417ECL.Level_8, default is PDF417ECL.Level_2. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: RowCount
URL: ROW-COUNT |
Type: int
Default: 3 |
The number of rows for PDF417. The value range is from 3 to 90. The default is 3. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: ColumnCount
URL: COLUMN-COUNT |
Type: int
Default: 5 |
Number of columns. The value range is from 1 to 30. The default is 5. Increase this value, if your data size is large. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Truncated
URL: TRUNCATED |
Type: bool
Default: false |
truncated PDF417 may be used where space considerations are a primary concern and symbol damage is unlikely. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Macro
URL: MACRO |
Type: bool
Default: false |
Set isMacro property to true, then Macro PDF417 is enabled. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: MacroSegmentIndex
URL: MACRO-SEGMENT-INDEX |
Type: int
Default: 0 |
the position of current symbol in the secuence (Start with 0). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: MacroSegmentCount
URL: MACRO-SEGMENT-COUNT |
Type: int
Default: 0 |
the number of total symbols which make the sequence. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: MacroFileIndex
URL: MACRO-FILE-INDEX |
Type: int
Default: 0 |
be identified to the same file | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Barcode Size Related |
Property: X
URL: X |
Type: float
Default: 2 |
Barcode bar module width, default is 3 pixel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: XtoYRatio
URL: X-Y-RATIO |
Type: float
Default: 0.3333333f |
Bar width vs bar height ratio | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
UPC/EAN Barcodes Options (EAN-13, EAN-8, UPC-A, UPC-E)
| Category | Properties | Value | Comments |
| UPC/EAN
Barcode Related |
Property: UPCEANLeadDigitSpace |
Type: float
Default: 0f |
The space between the first digit and the left side of the barcode |
| Property: UPCEANTrailDigitSpace |
Type: float
Default: 0f |
The space between the last digit and the right side of the barcode | |
| Property: UPCEANLeadTrailDigitSizeRatio |
Type: float
Default: 1f |
The first and last digits size vs the other digits' size | |
| Property: UPCENumber |
Type: int
Default: 0 |
For UPC-E barcode only, the UPC-E barcode number system. | |
| Property: ShowQuietZoneIndicator |
Type: bool
Default: true |
Whether display UPC/EAN quiet zone indicator mark or not. |
Add-on Barcodes Options (EAN-13, EAN-8, UPC-A, UPC-E, ISBN, ISSN)
| Category | Properties | Value | Comments |
| Supplemental
Barcode Related |
Property: SupData
URL: SUP-DATA |
Type: string
Default: "" |
Set the supplement data to encode. Valid values are 2 or 5 digits |
|
Property: SupHeight
URL: SUP-HEIGHT |
Type: float
Default: 0.8f |
This is a multiplicator of the height of the bar module; The default is 0.8 (80% of Y - bar module height). | |
|
Property: SupSpace
URL: SUP-SPACE |
Type: float
Default: 15 |
The separation between the barcode and the supplement. Default is 15 pixel. |
Barcode Exception
| Category | Properties | Value | Comments |
| Exception
Related |
Property: ExceptionMode |
Type: ExceptionMode
Default: ExceptionMode.ShowErrorImage |
When the barcode library cannot create a barcode successfully,
the software will either generate an image with "Invalid Barcode Settings" message printed, or through Exception in the program.
You can find the details here: How to handle exception during barcode generation in C#? |
List of Barcode methods
// generate barcode and encode to image file public void drawBarcode(string filename) // generate barcode and paint on Graphics object public void drawBarcode(Graphics graphics) // generate barcode and paint on Bitmap object public Bitmap drawBarcode() // generate barcode and paint on Stream object public void drawBarcode(Stream fileStream) // generate barcode and paint on byte[] object public byte[] drawBarcodeAsBytes() // generate barcode and encode to EPS file public void drawBarcode2EPS(string filename) // generate barcode in a EPS file stream public void drawBarcode2EPS(Stream fileStream) // generate barcode in a EPS file in byte[] object public byte[] drawBarcode2EPSAsBytes() // generate barcode and encode to SVG file public void drawBarcode2SVG(string filename) // generate barcode in a SVG file stream public void drawBarcode2SVG(Stream fileStream) // generate barcode in a SVG file in byte[] object public byte[] drawBarcode2SVGAsBytes() |
