Managing 2D Barcodes

Hiding CodeText that is too long to display

Unlike one dimensional barcode, two-dimensional barcodes often contain a huge amount of data, which is exactly why a two-dimensional barcode exists. We often print out the human-readable CodeText along with the barcode, this CodeText has nothing to do with machine scanning. In the case of two-dimensional barcodes, CodeText is simply too long to display. Under such a situation, a certain approach should be taken.

Hide BarCode CodeText

The following example shows how to hide the barcode CodeText.

Hiding CodeText’s

Reduce the font size of CodeText

The following example shows how to reduce the font size of CodeText

Adjusting 2D images size

Each specific type of barcode may have different semantic demands, then it will override or ignore the above settings. e.g. DataMatrix is a square-based type of barcode. The AspectRatio setting is meaningless to DataMatrix because AspectRatio has to be 1 for square modules. BarCodeBuilder will simply ignore those illegal settings and decide on its own during the process.

Setting Aspect Ratio of Barcodes

The Aspect Ratio of a barcode is the width:height ratio. We can control how tall or wide the barcode can be generated using the Aspect Ratio. 3:2 Aspect Ratio means the barcode is 1.5 or 3/2 times wider than taller. Or the width of the barcode is 1.5 times larger than the height. Below is a Pdf417 barcode with 1.5 Aspect Ratio:

BarCode with Aspect Ratio of 1.5
2 Aspect Ratio means the width of the barcode is 2 times greater than the height. Below is the Pdf417 barcode with an Aspect Ratio of 2.
BarCode with Aspect Ratio of 2
The code snippet to set the Aspect Ratio is given below:

Detect Unicode Encoding of Barcode

Aspose.BarCode API allows developers to detect the Unicode encoding. The flag works for QR/Micro QR at the moment.

In case, the detect encoding flag is enabled the barcode engine returns Unicode text while tries to detect the encoding of the barcode. The barcode may be encoded using one of the following encodings:

  • UTF8
  • BOM_UTF8

The flag is enabled by default. In case the flag is disabled the engine returns plain text without encoding detection.

The code example given below demonstrates how to get the plain text without encoding detection