---
title: "Advanced Barcode Generation"
app: "Barcode Generator PowerTool"
section: "Set up"
last_updated: "2025-10-30"
url: "https://insight-works.com/kb/barcode-generator-powertool/advanced-barcode-generation/"
---

# Advanced Barcode Generation

The main purpose of this extension is to provide a tool to developers that have a requirement to add barcodes to their reports or their client’s reports.

## Retrieve Barcode Generation Symbols

Before starting, ensure Barcode Generator is installed (see _Install and Uninstall Barcode Generator_). Once Barcode Generator is installed, you can download the symbols and use the generation functions. Complete the following to obtain the symbols:

1. Create an AL project in Visual Studio Code.
2. Configure the launch.json file for the desired Sandbox (see [_Launch JSON file_](https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-json-launch-file) for more information).
3. Include the Barcode Generation extension as a dependency in the dependencies portion of the app.json file.

```
  "dependencies": [
    {
      "id": "62080fe0-d57f-4d4c-aed1-ac539db3a244",
      "name": "Barcode Generator",
      "publisher": "Insight Works",
      "version": "1.0.0.0"
    }
  ]
```

1. Use the search window to select **AL: Download Symbols** while in the same project (downloads the sandbox’s symbol file into the .alpackages project folder).

You now have access to the Barcode Generation procedures. These may be used in your reports and can be deployed as a per tenant extension to your or your client’s Microsoft Dynamics 365 Business Central environment.

## Barcode Generation Functions

The procedures are contained in Codeunit 23044800 “IWX Library ‐ Barcode Gen”.

### GenerateMatrixBarcode

This function generates a 2D barcode in a Data Matrix format. The following parameters are in order of the function signature.

| **Parameter** | **Type** | **Input** | **Comment** |
| --- | --- | --- | --- |
| precBarcode | var Record “IWX Barcode” temporary | temporary “IWX Barcode” variable | When the function is successful, “IWX Barcode”.Image populates with the barcode image. |
| ptxtBarcodeContent | Text[1024] | barcode data | The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs. |
| piBarcodeImageSize | Integer | desired symbol size | Defines the symbol sizes, it can vary from 10×10 to 144×144 (int 1 = 10×10). You can use the Barcode Generator’s enumerator 23044803 IWX Barcode Image Size. |
| piBarcodeMultiplier | Integer | desired barcode resolution | The minimum value is 8, which translates to a size of 2px per dot. A multiplier of 16 equals 4px per dot. |

### GenerateMatrixBarcode override

This function generates a 2D barcode in a Data Matrix format. The following parameters are in order of the function signature.

| **Parameter** | **Type** | **Input** | **Comment** |
| --- | --- | --- | --- |
| pcuTempBlob | var Codeunit “Temp Blob”” | Codeunit “Temp Blob”” variable | When the function is successful, the instance of the codeunit variable contains the barcode image in the outstream. |
| ptxtBarcodeContent | Text[1024] | barcode data | The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs. |
| piBarcodeImageSize | Integer | desired symbol size | Defines the symbol sizes, it can vary from 10×10 to 144×144 (int 1 = 10×10). You can use the Barcode Generator’s enumerator 23044803 IWX Barcode Image Size. |
| piBarcodeMultiplier | Integer | desired barcode resolution | Defines the dot size with the minimum value of 8, which translates to a dot size of 2px2. A multiplier of 16 translates to 4px2 per dot. |

### GenerateQRBarcode

This function generates a 2D barcode in a QR format. The following parameters are in order of the function signature.

| **Parameter** | **Type** | **Input** | **Comment** |
| --- | --- | --- | --- |
| precBarcode | var Record “IWX Barcode” temporary | temporary “IWX Barcode” variable | When the function is successful, “IWX Barcode”.Image populates with the barcode image. |
| ptxtBarcodeContent | Text[1024] | barcode data | The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs. |
| piBarcodeDotSize | Integer | desired barcode resolution | Defines the dot size with the minimum value of 2, which translates to a dot size of 2px2. A value of 4 translates to a dot size 4px2. |

### GenerateQRBarcode override

This function generates a 2D barcode in a QR format. The following parameters are in order of the function signature.

| **Parameter** | **Type** | **Input** | **Comment** |
| --- | --- | --- | --- |
| pcuTempBlob | var Codeunit “Temp Blob”” | Codeunit “Temp Blob”” variable | When the function is successful, the instance of the codeunit variable contains the barcode image in the outstream. |
| ptxtBarcodeContent | Text[1024] | barcode data | The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs. |
| piBarcodeDotSize | Integer | desired barcode resolution | Defines the dot size with the minimum value of 2, which translates to a dot size of 2px2. A value of 4 translates to a dot size 4px2. |

### Generate39Barcode

This function generates a 1D barcode in the Code39 format. The following parameters are in order of the function signature.

| Parameter | Type | Input | Comment |
| --- | --- | --- | --- |
| precBarcode | var Record “IWX Barcode” temporary | temporary “IWX Barcode” variable | When the function is successful “IWX Barcode”.Image populates with the barcode image. |
| ptxtBarcodeContent | Text[1024] | barcode data | The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned will be unique to your needs. |
| piWidth | Integer | desired width in pixels |  |
| piHeight | Integer | desired height in pixels |  |

###

Generate39Barcode override

This function generates a 1D barcode in the Code39 format. The following parameters are in order of the function signature.

| **Parameter** | **Type** | **Input** | **Comment** |
| --- | --- | --- | --- |
| pcuTempBlob | var Codeunit “Temp Blob”” | Codeunit “Temp Blob”” variable | When the function is successful, the instance of the codeunit variable contains the barcode image in the outstream. |
| ptxtBarcodeContent | Text[1024] | barcode data | The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs. |
| piWidth | Integer | desired width in pixels |  |
| piHeight | Integer | desired height in pixels |  |

### GenerateGS1128Barcode

 Note: To include a Function 1 character (FNC1) as a group separator or to terminate a non-predefined length Application Identifier in a GS1128 barcode, insert inserted in the appropriate position of the barcode content “~FNC1~” (an FNC1 character is automatically included at the start of the barcode for GS1128 barcodes).

This function generates a 1D barcode in the Code128 format. The following parameters are in order of the function signature.

| **Parameter** | **Type** | **Input** | **Comment** |
| --- | --- | --- | --- |
| precBarcode | var Record “IWX Barcode” temporary | Temporary “IWX Barcode” variable | When the function is successful, “IWX Barcode”.Image populates with the barcode image. |
| ptxtBarcodeContent | Text[1024] | Barcode data | The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs. By default, brackets and spaces will be removed. |
| piDPi | Integer | Dots Per Inch | Defines barcode resolution, the higher the number, the more detail in the image. Note that DPI affects height. |
| piHeight | Integer | Height by Pixel | Defines the barcode height. Note that DPI affects the height. |
| pbIsSymbolParsed | Boolean | Optional | Defaults to false. If true, brackets and spaces will be included in the barcode. |

###

GenerateGS1128Barcode override

 Note: To include a Function 1 character (FNC1) as a group separator or to terminate a non-predefined length Application Identifier in a GS1128 barcode, insert inserted in the appropriate position of the barcode content “~FNC1~” (an FNC1 character is automatically included at the start of the barcode for GS1128 barcodes).

This function generates a 1D barcode in the Code128 format. The following parameters are in order of the function signature.

| **Parameter** | **Type** | **Input** | **Comment** |
| --- | --- | --- | --- |
| pcuBarcode | Var Codeunit “Temp Blob” | Codeunit “IWX Barcode” variable | When the function is successful, the instance of the codeunit variable contains the barcode image in the outstream. |
| ptxtBarcodeContent | Text[1024] | Barcode data | The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs. By default, brackets and spaces will be removed. |
| piDPi | Integer | Dots Per Inch | Defines barcode resolution, the higher the number, the more detail in the image. Note that DPI affects the height. |
| piHeight | Integer | Height by Pixel | Defines the barcode height. Note that DPI affects the height. |
| pbIsSymbolParsed | Boolean | Optional | Defaults to false. If true, brackets and spaces will be included in the barcode. |

###

## Barcode Generation Helper Functions

The procedures are contained in Codeunit 23044800 – IWX Library – Barcode Gen.

### GetBarcodeFormat

This function is used for leveraging user-defined barcode document prefixes in the _Barcode Setup_ page. The following parameters are in order of the function signature.

| **Parameter** | **Type** | **Input** | **Comment** |
| --- | --- | --- | --- |
| ptxtCode | var Codeunit “Temp Blob”” | Codeunit “Temp Blob”” variable | The raw barcode content. |
| peDocument | Enum “IWX Documents” | An enumerator from the Enum 23044801 – IWX Documents. | The barcode content is prefixed with the document’s prefix value set in the _Barcode Setup_ page. |

| **Return Value** | **Type** | **Comment** |
| --- | --- | --- |
| Barcode Content | Text[1024] | The raw barcode content prefixed. |

###

GetBarcodeFormat override

This function is used for activities barcodes, leveraging user-defined barcode document prefixes and activity suffixes in the _Barcode Setup_ page. The following parameters are in order of the function signature.

| **Parameter** | **Type** | **Input** | **Comment** |
| --- | --- | --- | --- |
| ptxtCode | var Codeunit “Temp Blob”” | Codeunit “Temp Blob”” variable | The raw barcode content. |
| peDocument | Enum “IWX Documents” | An enumerator from the Enum 23044801 – IWX Documents. | The barcode content is prefixed with the document’s prefix value set in the _Barcode Setup_ page. |
| peActivity | Enum “IWX Activities” | An enumerator from the Enum 23044800 – IWX Activities | The barcode content is suffixed with the warehouse activities’ suffix value set in the _Barcode Setup_ page. |

| **Return Value** | **Type** | **Comment** |
| --- | --- | --- |
| Barcode Content | Text[1024] | The raw barcode content prefixed and suffixed. |

## Use Barcode Generation in a Report

These functions return an IWX Barcode object that has the barcode image set in the _Image_ field. That _Image_ field may be used in a DataItem column, which shows up where referenced in the report layout.

### Report Object

In the report object you would set the value under the relevant DataItem. In the example below “100” is replaced with the string that represents the data you would like to have included in the barcode.

```
dataitem(Loop; "Integer")

{

DataItemTableView = SORTING (Number);

column(barcodeImage; Barcode.Image)

{

}

trigger OnPreDataItem();

begin

SETRANGE(Number, 1, 1);

end;

trigger OnAfterGetRecord();

BarcodeGeneration: Codeunit "IWX Library - Barcode Gen";

begin

BarcodeGeneration.Generate39Barcode(Barcode, '100',

550, 220);

end;

}

var

Barcode: Record “IWX Barcode” temporary;
```

### Report Layout

Include this column in the report layout by adding an image element. Based on the above example, the properties would look like the following:

```
field: =First(Fields! barcodeImage.Value, "DataSet_Result")

Source: Database

MIME: image/bmp

Display: Fit proportional
```
