Sunday, January 30, 2022

Print QR Code & Data Matrix in Business Central SaaS Version - New Very Simple Method

Hello Friends, 

From BC 19.1 version 2D Fonts available in BC Version (Free !!!!)

Microsoft added this feature 

Simple 4 line code to generate it.

report 67467 ItemBarCode
{
    UsageCategory = Administration;
    ApplicationArea = All;
    DefaultLayout = RDLC;
    Caption = 'Item Barcodes';
    RDLCLayout = 'ItemBarcodes.rdl';
    dataset
    {
        dataitem(Item; Item)
        {
            DataItemTableView = sorting("No.");
            RequestFilterFields = "No.";
            RequestFilterHeading = 'Items';
            column(No_; "No.")
            {
            }
            column(Description; Description)
            {
            }
            column(DataMatrix; DataMatrix)
            {
            }
            column(QRCode; QRCode)
            {
            }
            trigger OnAfterGetRecord()
            begin
                GenerateDataMatrix();
                GenerateQRCode();
            end;
        }
    }

    local procedure GenerateDataMatrix()
    var
        BarcodeSymbology2D: Enum "Barcode Symbology 2D";
        BarcodeFontProvider2D: Interface "Barcode Font Provider 2D";
        BarcodeString: Text;
    begin
        BarcodeFontProvider2D := Enum::"Barcode Font Provider 2D"::IDAutomation2D;
        BarcodeSymbology2D := Enum::"Barcode Symbology 2D"::"Data Matrix";
        BarcodeString := Item."No.";
        DataMatrix := BarcodeFontProvider2D.EncodeFont(BarcodeString, BarcodeSymbology2D);
    end;

    local procedure GenerateQRCode()
    var
        BarcodeSymbology2D: Enum "Barcode Symbology 2D";
        BarcodeFontProvider2D: Interface "Barcode Font Provider 2D";
        BarcodeString: Text;
    begin
        BarcodeFontProvider2D := Enum::"Barcode Font Provider 2D"::IDAutomation2D;
        BarcodeSymbology2D := Enum::"Barcode Symbology 2D"::"QR-Code";
        BarcodeString := Item."No." + ' | ' + Item.Description + '|' + Format(CurrentDateTime);
        QRCode := BarcodeFontProvider2D.EncodeFont(BarcodeString, BarcodeSymbology2D);
    end;

    var

        DataMatrix: Text;

        QRCode: Text;
}

Create Layout and enter font name manual in text box









Font Name - IDAutomation2D

Note – Font name not available in list but you can simple enter it manual, It will work fine.



















Done…..

So Simple…..










I hope this blog help someone to develop it.

Thank you for reading...

Keep Sharing....Keep Growing....

No comments:

Post a Comment