Advanced Barcode Generation

Home/Advanced Barcode Generation

Advanced Barcode Generation

You are here:

The Barcode Generator extension provides developers with a tool 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. Set the launch.json file in the project to the Microsoft Dynamics 365 Business Central sandbox.

Note: The sandbox it connects to depends on your login information.

{
“version”: “0.2.0”,
“configurations”: [
{
“type”: “al”,
“request”: “launch”,
“name”: “Microsoft cloud sandbox”,
}
]}

     3. Include the Barcode Generation extension as a dependency in the dependencies portion of the app.json file.

{ "version": "0.2.0", "configurations": [ { "type": "al", "request": "launch", "name": "Microsoft cloud sandbox", } ] }

“dependencies”: [
{
“appId”: “62080fe0-d57f-4d4c-aed1-ac539db3a244”,
“publisher”: “Insight Works”,
“name”: “Barcode Generator”,
“version”: “1.1.2.0”
}
]

     4. Input AL: Download Symbols into the search window (downloads the symbol file from the sandbox into the .alpackages project folder).

Note: You now have access to the Barcode Generation procedures. These may be used in your reports that can be deployed as a per-tenant extension to the Microsoft Dynamics 365 Business Central environment.

Barcode Generation Functions

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

GenerateDataMatrixBarcode

The GenerateDataMatrixBarcode function generates a 2D barcode. The following parameters are organized by the function signature.

Parameter Type Input Comment
ptrecBarcode var Record TempBlob temporary temporary TempBlob variable When the function is successful, the TempBlob populates with the barcode image.
ptxtBarcode Text[1024] barcode data Creates the barcode image with the information contained within this string. The format and interpretation of the string when the barcode is scanned is unique to your needs.
piBarcodeDotSize Integer desired dot size

DataMatrix.Net uses these 3 fields to determine the height and width (in pixels) of the resulting image. The options for the margin size are based on the DataMatrix.Net library.

width = 2 * this._marginSize + (this._region.SymbolCols * this._moduleSize);

height = 2 * this._marginSize + (this._region.SymbolRows * this._moduleSize);

piBarcodeMarginSize Integer desired margin size
piBarcodeImageSize Integer Integer selection from below
    0 Auto
1 10×10
2 12×12
3 14×14
4 16×16
5 18×18
6 20×20
7 22×22
8 24×24
9 26×26
10 32×32
11 36×36
12 40×40
13 44×44
14 48×48
15 52×52
16 64×64
17 72×72
18 80×80
19 88×88
20 96×96
21 104×104
22 120×120
23 132×132
24 144×144
25 8×18
26 8×32
27 12×26
28 12×36
29 16×36
30 16×48

Generate39Barcode

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

Parameter Type Input Comment
ptrecBarcode var Record TempBlob temporary temporary TempBlob variable Populates TempBlob variable with the barcode image when the function is successful.
ptxtBarcode Text[1024] barcode data Creates the barcode image using the string information.
The format and interpretation of the string when the barcode is scanned is unique to your needs.
piWidth Integer desired width in pixels  
piHeight Integer desired height in pixels  

Use Barcode Generation in a Report

These functions return a TempBlob object that has the barcode image set in the Blob field. The Blob field may then be used in a DataItem column which will show up where referenced in the report layout.

Report Object

Set the value under the relevant DataItem in the report object.

Note: In the example below ‘100’ would be replaced with whatever string represents the data you would like to have included in the barcode.

dataitem(Loop; “Integer”)
{
DataItemTableView = SORTING (Number);
column(barcodeBlob; TempBlob.Blob)
{
}
trigger OnPreDataItem();
begin
SETRANGE(Number, 1, 1);
end;
trigger OnAfterGetRecord();
BarcodeGeneration: Codeunit “IWX Library – Barcode Gen”;
begin
BarcodeGeneration.Generate39Barcode(TempBlob, ‘100’,
550, 220);
end;
}

Report Layout

Add an image element to include the column in the report layout. Based on the above example, the properties will look like the following:

field: =First(Fields!barcodeBlob.Value, “DataSet_Result”)
MIME: image/bmp
Display: Fit proportional

Was this article helpful?
1.8 out of 5 stars
5 Stars 0%
4 Stars 33%
3 Stars 0%
2 Stars 0%
1 Stars 67%
How can we improve this article?
Need help?

Leave A Comment

Go to Top