Skip to end of metadata
Go to start of metadata
  

Create Two Dimensional (2D) Barcodes

Two dimensional barcode can contain more data per label, up to thousands of characters. Large amounts of text and data can be stored securely and inexpensively when using Aspose.BarCode to encode.BarCodeBuilder supports both one dimensional and two dimensional barcodes. It encapsulate both types of barcode into one unified interface. Creating two dimensional barcodes is just the same as creating one dimensional barcodes.

Create a pdf417 barcode

The following code snippet shows you how to create a pdf417 barcode.

Create a datamatrix barcode

The following code snippet shows you how to create a datamatrix barcode.

Create a PDF417 Barcode

Data File 417, is a two-dimensional stacked barcode symbology capable of encoding over a kilobyte of data per label. It was developed by Symbol Technologies (1989-1992) and is currently maintained by ANSI/AIM USA. To create an Pdf417 barcode please follow below steps.

  1. Instantiate a BarCodeBuilder
  2. Set up its SymbologyType property to be Pdf417
  3. Set CodeText property for the data you want to encode

Pdf417 Error correction level

Pdf417 barcode with error correction can withstand certain kind of damage. BarCodeBuilder with a higher error correction level will produce a bigger image, here is a sample with maximum error correction levels:

Truncated Pdf417

Aspose.BarCode supports truncated Pdf417 version which omits the right-hand side quiet zone in order to save space. Setting Pdf417Truncate property to true will lead to a comparatively smaller image.

Rows and columns

Rows and columns settings are aiming at general two dimensional barcodes, appliable to Pdf417. A Pdf417 barcode consists of black and white rectangular modules. If Rows and Columns settings are illegal, encoder will simply ignore those settings. Setting Rows and Columns to be zero means no Rows and Columns settings.The following sample pictures are Pdf417 barcodes with the same CodeText but of different Rows and Columns settings:

Different Rows and Columns settings

Pdf417 Compaction Mode

Setting Pdf417CompactionMode property will set the corresponding compaction mode. Below are the 4 modes that can be set using Aspose.BarCode for C++ Auto: Automatically detect compaction mode

  • Text: Text compaction, suitable for text data
  • Numeric: Numeric compaction mode, suitable for numeric data
  • Binary: Binary compaction mode, suitable for binary data
    Below code snippet generates a Pdf417 barcode using the Text compaction mode:

 

Please note that the barcode size is bigger, because we applied Binary compaction mode to encode a text data. You may set the Compaction mode to Auto for choosing the best possible compaction mode or choose carefully based on the type of codetext value.

Create a Datamatrix Barcode

DataMatrix is being used to encode product and serial number information on electrical rating plates; to mark of surgical instruments in Japan; to identify lenses, circuit boards, and other items during manufacturing. DataMatrix barcodes can store up to 2000 characters. Aspose.BarCode provides the most convenient way of producing an DataMatrix type of two dimentional barcode.

How to produce a Datamatrix barcode

Instantiate a BarCodeBuilder and set its SymbologyType to be DataMatrix, and set its CodeText property for the data you want to encode

Encode mode

Aspose.BarCode supports several types of encode mode for DataMatrix, which is default to Auto, indicating the encoder to choose a best encode mode.
What is the best encode mode?. The best encode mode will likely produce the smallest picture under the same settings. What the encoder does is trying to encode two characters into one single byte. The following code snippet shows you how to use encode mode.

Custom Encoding Mode

Aspose.BarCode now supports the Custom encode mode for DataMatrix in order to support Encoding standard like UTF8. The following code snippet shows you how to use custom encoding mode.

Create a Aztec Barcode

Aztec barcode is a square grid high density two dimensional barcode symbology which can encode up to 3,000 alphanumeric characters.

How to produce an Aztec barcode

Instantiate an BarCodeBuilder and set its SymbologyType to Symbology.Aztec, and set its CodeText property for the data you want to encode. The following code snippet shows you how to generate a Aztec barcode.

Error correction

Aztec barcode allows code recovery when the barcode image is partly damaged, error correction level is ranging from 10% to 90%. Below is an example of setting up Aztec barcode's error correction level. Aztec barcode sample with different error correction levels.

Create a QR or Micro QR Barcode

QR barcode is a two dimensional barcode symbology developed in Japan. QR barcode has the following features:

  • High capacity encoding of data, upto 7000 numeric digits or 4000 alphanumeric data
  • Dirt and damage resistant, a maximum 30% of code words can be restored
  • Readable from all directions

Added a QREncodeType property in BarCodeBuilder Class. This new property works as QR / MicroQR selector. Select ForceQR (default) for standard QR symbols, Auto for MicroQR.

Enum QREncodeType:

  1. Auto - mode starts barcode version negotiation from MicroQR V1
  2. ForceQR – mode starts barcode version negotiation from QR V1
  3. ForceMicroQR - mode starts barcode version negotiation from MicroQR V1 to V4. If data cannot be encoded into MicroQR, exception is thrown.

Added changes to Enum QREncodeMode:

  1. Auto - encode codetext as is non-unicode charset. If there is any unicode character, the codetext will be encoded with value which is set in CodeTextEncoding.
  2. Bytes - encode codetext as plain bytes. If it detects any unicode character, the character will be encoded as two bytes, lower byte first;
  3. Utf8BOM - encode codetext with UTF8 encoding with first ByteOfMark character;
  4. Utf16BEBOM - encode codetext with UTF8 encoding with first ByteOfMark character. It can be problems with some barcode scaners;
  5. ECIEncoding - encode codetext with value set in the ECIEncoding property. It can be problems with some old (pre 2006) barcode scaners.
  6. ExtendedCodetext - encode codetext in Extended Channel mode which supports FNC1 first position, FNC1 second position and multi ECI modes.

Encoding of a QR and Micro QR Barcode

Micro QR code is a smaller version of the QR code standard for applications where symbol size is limited. There are 4 different versions (sizes) of Micro QR codes: the smallest is 11×11 modules; the largest can hold 35 numeric characters.

Error correction

QR barcode can withstand certain damage and can still be decoded normally. This is decided by QR barcode's error correction level during encode. There are four levels of error correction, from low to high:

  • LevelL. Allows recovery of 7% of the code text
  • LevelM. Allows recovery of 15% of the code text
  • LevelQ. Allows recovery of 25% of the code text
  • LevelH. Allows recovery of 30% of the code text

How to Encode QR Code

Instantiate a BarCodeBuilder class object and set its SymbologyType to be Symbology.QR, and set its CodeText property, QREncodeMode to auto, QREncodeType to ForceQR and set error correction level for the data you want to encode. Below is an example to generate a QR barcode.

How to set QR version

Aspose.BarCode for .NET allow developers to set version of QR barcode while generating the barcode. A property QRVersion has been introduced in the BarCodeBuilder class to achieve the goal. Following is the sample code demonstration how to set QR version before generating barcode image.

How to Encode MicroQR Code

Instantiate a BarCodeBuilder class object and set its SymbologyType to be Symbology.QR, and set its CodeText property, QREncodeMode to auto, QREncodeType to auto and set error correction level for the data you want to encode. The following code snippet shows you how to generate a MicroQR barcode.

Generate Multiple MacroPdf417 Barcodes for Large or Multiple Codetext Values

Multiple MacroPdf417 barcodes can be generated if we either have multiple codetext values or a very large codetext value. In case of large codetext value, we may break the large value into multiple smaller codetext values and generate multiple MacroPdf417 barcodes for these. Each generated barcode maintains the File ID and Segment ID , so that these could be recognized in correct series. Last segment flag is also set in the last barcode. The following code snippet shows you how to generate four MacroPdf417 barcodes for 4 different codetext values.

Create C40 Encoded Datamatrix Barcode

Aspose.BarCode for .NET now supports creating Datamatix barcode with C40 encodation scheme. Following code snippet demonstrates how simple it is to create C40 encoded barcode.

Create Text Encoded Datamatrix Barcode

Aspose.BarCode for .NET now supports creating Datamatix barcode with Text encodation scheme. Following code snippet demonstrates how simple it is to create Text encoded barcode.

Create Barcode with Image In Place of Codetext

Aspose.BarCode for .NET allow developers to generating barcode with logo/other image inside it instead of codetext. How developers can embed a logo/image/picture in place of codetext inside the barcode is very simple. Following is the sample code demonstration.

Labels
  • No labels