Skip to end of metadata
Go to start of metadata
  

Encode multi-ECI and FNC1 Symbols in QR Code

The ExtendedCodetext mode allows developers to encode multi-ECI and FNC1 symbols in the QR code. Extended Channel mode supports FNC1 first position, FNC1 second position and multi ECI modes.

QR Code Encoding in the Extended Code Text Mode

Aspose.BarCode APIs use QrExtCodetextBuilder class for extended code text generation. Use Display2DText property of the BarCodeBuilder class to set visible text and removing managing characters display.

Encoding Principles:

  • All symbols "\" must be doubled in the codetext.
  • FNC1 in first position is set in codetext as as "<FNC1>".
  • FNC1 in second position is set in codetext as as "<FNC1(value)>". The value must be single symbols (a-z, A-Z) or digits from 0 to 99.
  • Group Separator for FNC1 modes is set as 0x1D character '\u001D'.
  • If you need to insert "<FNC1>" string into barcode write it as "<\FNC1>".
  • ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier.
  • TO disable current ECI mode and convert to default JIS8 mode zero mode ECI indetifier is set "\000000".
  • All unicode characters after ECI identifier are automatically encoded into correct character codeset.

QrExtCodetextBuilder class description:

  • Clear() method - clears extended codetext items.
  • AddPlainCodetext(System.String) method - adds plain codetext to the extended codetext items.
  • AddECICodetext(Aspose.BarCode.ECIEncodings,System.String) method - Adds codetext with Extended Channel Identifier.
  • AddFNC1FirstPosition() method - adds FNC1 in first position to the extended codetext items.
  • AddFNC1SecondPosition(System.String) method - adds FNC1 in second position to the extended codetext items.
  • AddFNC1GroupSeparator() method - Adds Group Separator (GS - '\u001D') to the extended codetext items.
  • GetExtendedCodetext() method - generates extended codetext from generation items list.

Use FNC1 First Position in Extended Mode

Instantiate a QrExtCodetextBuilder class object, call AddFNC1FirstPosition method to set FNC1 in first position of the extended code text items, call AddPlainCodetext method to add plain code text to the extended code text items, call AddFNC1GroupSeparator method to add group separator in the extended code text items and then call AddPlainCodetext method to add plain code text to the extended code text items.

Use FNC1 Second Position in Extended Mode

Instantiate a QrExtCodetextBuilder class object, call AddFNC1SecondPosition method to set FNC1 in second position of the extended code text items and then call AddPlainCodetext method to add plain code text to the extended code text items.

 

Use multi ECI Mode in Extended Mode

Instantiate a QrExtCodetextBuilder class object, call AddECICodetext method multiple times to add code text with extended channel identifier and then call AddPlainCodetext method to add plain code text to the extended code text items.

 

MicroQR cannot support ECI and FNC1 modes. In this way if you want to generate MicroQR code you must use current modes of QREncodeMode: Auto, Bytes, Utf8BOM and Utf16BEBOM.

Hiding CodeText that is too long to display

Unlike one dimensional barcodes, two dimensional barcodes often contain huge amount of data, which is exactly why 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 case of two dimensional barcodes, CodeText is simply too long to display. Under such situation, 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

The size of a barcode image depends on many factors. Mainly the following settings will affect the size of the overall image:

  • Metrics
  • Resolution, Higher resolution will lead to larger image on the same screen or printer.
  • GraphicsUnit, Whether all the settings are based on millimeter or inches etc.
  • The overall image
  • AutoSize, set to false means the image's size is fixed to ImageWidth * ImageHeight. Over sized barcode (e.g. CodeText very long) will be out of frame if AutoSize is false and the size not large enough
  • ImageWidth, only valid when AutoSize set to false
  • ImageHeight, only valid when AutoSize set to false
  • Margins, only valid when AutoSize is true, indicates the marginal area of the core barcode. This setting could be overrided by CaptionAbove and CaptionBelow. That is, when AutoSize is true, and the Margins setting is not large enough to display the CaptionAbove or CaptionBelow, then the marginal area will expand automatically
  • CaptionAbove, Controlled by CaptionAbove.Visible, CaptionAbove.Space and CaptionAbove.Font
  • CaptionBelow, Controlled by CaptionBelow.Visible, CaptionBelow.Space and CaptionBeow.Font
  • The core barcode
  • xDimension, each (1D) black bar's or (2D) module's width
  • yDimension, each (2D) module's height
  • Rows, number of (2D) module rows
  • Columns, number of (2D) module columns
  • AspectRatio, the ratio of yDimension/xDimension
  • WideNarrowRatio, the ratio of wide bars / narrow bars or wide spaces / narrow spaces for some types of barcodes
  • CodeText, controlled by CodeLocation, CodeTextFont and CodeTextSpace

Each specific type of barcode may have different semantic demands, then it will override or ignore the above settings. e.g. DataMatrix is 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 barcode is 2 times greater than the height. Below is the Pdf417 barcode with 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
  • BOM_UTF16BE
  • BOM_UTF16LE

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

Below is an example to get plain text without encoding detection

QR Code Encoding in the ECI Mode

ECI (Extended Channel Interpretation) enables QR Code encode multiple character sets (e.g. Arabic, Cyrillic, Greek, Hebrew) and other data interpretations or industry specific requirements to be represented, into one QR Code symbol.

Added the new property ECIEncoding to BarCodeBuilder class. It is used to tell the barcode reader details about the used references for encoding the data in the symbol by the Extended Channel Interpretation Identifiers. Current implementation consists all well-known charset encodings. Currently, it is used only for QR 2D barcode.

Enum ECIEncodings:

  1. ISO_8859_1 - ISO/IEC 8859-1 Latin alphabet No. 1 encoding. ECI Id:"\000003".
  2. ISO_8859_2 - ISO/IEC 8859-2 Latin alphabet No. 2 encoding. ECI Id:"\000004".
  3. ISO_8859_3 - ISO/IEC 8859-3 Latin alphabet No. 3 encoding. ECI Id:"\000005".
  4. ISO_8859_4 - ISO/IEC 8859-4 Latin alphabet No. 4 encoding. ECI Id:"\000006".
  5. ISO_8859_5 - ISO/IEC 8859-5 Latin/Cyrillic alphabet encoding. ECI Id:"\000007".
  6. ISO_8859_6 - ISO/IEC 8859-6 Latin/Arabic alphabet encoding. ECI Id:"\000008".
  7. ISO_8859_7 - ISO/IEC 8859-7 Latin/Greek alphabet encoding. ECI Id:"\000009".
  8. ISO_8859_8 - ISO/IEC 8859-8 Latin/Hebrew alphabet encoding. ECI Id:"\000010".
  9. ISO_8859_9 - ISO/IEC 8859-9 Latin alphabet No. 5 encoding. ECI Id:"\000011".
  10. ISO_8859_10 - ISO/IEC 8859-10 Latin alphabet No. 6 encoding. ECI Id:"\000012".
  11. ISO_8859_11 - ISO/IEC 8859-11 Latin/Thai alphabet encoding. ECI Id:"\000013".
  12. ISO_8859_13 - ISO/IEC 8859-13 Latin alphabet No. 7 (Baltic Rim) encoding. ECI Id:"\000015".
  13. ISO_8859_14 - ISO/IEC 8859-14 Latin alphabet No. 8 (Celtic) encoding. ECI Id:"\000016".
  14. ISO_8859_15 - ISO/IEC 8859-15 Latin alphabet No. 9 encoding. ECI Id:"\000017".
  15. ISO_8859_16 - ISO/IEC 8859-16 Latin alphabet No. 10 encoding. ECI Id:"\000018".
  16. Shift_JIS - Shift JIS (JIS X 0208 Annex 1 + JIS X 0201) encoding. ECI Id:"\000020".
  17. Win1250 - Windows 1250 Latin 2 (Central Europe) encoding. ECI Id:"\000021".
  18. Win1251 - Windows 1251 Cyrillic encoding. ECI Id:"\000022".
  19. Win1252 - Windows 1252 Latin 1 encoding. ECI Id:"\000023".
  20. Win1256 - Windows 1256 Arabic encoding. ECI Id:"\000024".
  21. UTF16BE - ISO/IEC 10646 UCS-2 (High order byte first) encoding. ECI Id:"\000025".
  22. UTF8 - ISO/IEC 10646 UTF-8 encoding. ECI Id:"\000026".
  23. US_ASCII - ISO/IEC 646:1991 International Reference Version of ISO 7-bit coded character set encoding. ECI Id:"\000027".
  24. Big5 - Big 5 (Taiwan) Chinese Character Set encoding. ECI Id:"\000028".
  25. GB18030 - GB (PRC) Chinese Character Set encoding. ECI Id:"\000029".
  26. EUC_KR - Korean Character Set encoding. ECI Id:"\000030".

QR Code Encoding in the ECI Mode

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

Labels
  • No labels