Display String as barcode

Display String as barcode

There are several different classes in AX which can convert a simple string to a specific barcode format. I used the following example to convert a string to a EAN128 barcode and display it in a simple dialog in AX2012R3:

Which font code you need is declared in the classes “Barcode*” classes. You can initialize them with a construct and the barcode type and call the method “defaultFont()”.

void clicked()
    Dialog      dialog;
    DialogText dialogText;
    FormStringControl barcodeStringControl;
    BarcodeCode128 barcode = BarcodeCode128::construct();
    AccountNum account = "000000139";

    dialog = new Dialog();
    dialogText = dialog.addText(account );
    barcodeStringControl = dialogText.control();
    barcodeStringControl.font("BC C128 HD Wide");
    barcodeStringControl.text(barcode.encodeString(account ));


Leave a Comment