Advanced Barcode Generation

Home/Advanced Barcode Generation

Advanced Barcode Generation

You are here:

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

Retrieve Barcode Generation Symbols

Using the product in this way does require that the tenant have Barcode Generator installed. It will then be possible to download the symbols and use the generation functions. Here are steps on how to acquire the symbols.

  • Create an AL project in Visual Studio Code
  • Set the launch.json file in the project to the Microsoft Dynamics 365 Business Central sandbox. Which sandbox it connects to will depend on your login information.

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

  • 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”
}
]

  • While in that same project use the search window to select “AL: Download Symbols.” This should download the symbol file from the sandbox in to the .alpackages folder in the project.
  • You now have access to the Barcode Generation procedures. These may be used in your own reports that can then 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.

GenerateDataMatrixBarcode

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

Parameter Type Input Comment
ptrecBarcode var Record TempBlob temporary temporary TempBlob variable When the function is successful the TempBlob will be populated with the barcode image.
ptxtBarcode Text[1024] barcode data The barcode image will be 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.
piBarcodeDotSize Integer desired dot size

These 3 fields are used by DataMatrix.Net to determine the height and width (in pixels) of the resulting image. The options for the margin side 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 When the function is successful the
TempBlob will be populated with the
barcode image.
ptxtBarcode Text[1024] barcode data The barcode image will be 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  

Use Barcode Generation in a Report

These functions return a TempBlob object that has the barcode image set in the Blob field. That blob field may then be used in a DataItem column which will show 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’ 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

Next you will want to include this column in the report layout. To do so you would add an image element. Based on the above example the properties would look like the following.

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

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

Leave A Comment

Go to Top