web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

How Print QR Code In Report In AL (Business Central)

(2) ShareShare
ReportReport
Posted on by 322
Hello
A question for those with experience
I want a way to print the QR code on the report as an image. The text of the barcode is as follows:
AQACAnt9AwVmYWxzZQQGMTk0OC4yBQYxMDM0NzUGATAHCjIwMjQtMTItMzEICDE2NjMzMzc3CRlDUk9OVVMgSW50ZXJuYXRpb25hbCBMdGQuCmBNRVVDSUhERURzRmd2NEZwcEw0WGZ5RFVOWFRCTEtNemFONGo2YlZoMVBjdWFsblVBaUVBa2ovbm5lbERXRXE3SjBhQXlkYVJqS2JTSXFPRFZkNXFIT2ZsNU5iKy9CQT0=    
 
When I went to the barcode generation site "www.qr-code-generator.com", the barcode was generated correctly, as is clear in the following :
 
 
 
When I execute the code below, it gives me a blank image
 
 
 
 
 
Here is the simplest way to successfully print the barcode as an image
 
 
 
AL Code:
 
report 50009 "Contact_Sales_Invoice_QR"
{
    DefaultLayout = RDLC;
    RDLCLayout = './Report Layout/Invoice_Insight_With_QR_Code.RDL';
    EnableExternalImages = true;
 
    dataset
    {
        dataitem("Sales Invoice Header"; "Sales Invoice Header")
        {
            column(Invoice_No; "No.")
            {
            }
            column(Document_No; "No.")
            {
            }
            column(Invoice_Date; "Posting Date")
            {
            }
 
            column(Currency_Code; "Currency Code")
            {
            }
            column(Customer_No; "Bill-to Customer No.")
            {
            }
            column(Customer_Name; CustomerName
            {
            }
 
            column(Customer_City; CityName
            {
            }
            column(Customer_County; CountyName
            {
            }
            column(Subtotal; TotalSubtotal)
            {
            }
            column(Discount; TotalDiscount)
            {
            }
            column(SalesTax; TotalTax)
            {
            }
            column(Total; TotalNet)
            {
            }
            column(QR_Code; QRCodeText) // إضافة QR Code هنا
            {
            }
 
            dataitem("Sales Invoice Line"; "Sales Invoice Line")
            {
                DataItemLink = "Document No." = FIELD("No.");
                column(Description; Description)
                {
                }
                column(Amount_Line; "Line Amount")
                {
                }
            }
 
            trigger OnAfterGetRecord()
            var
                SalesInvoiceLine: Record "Sales Invoice Line";
                QRTable: Record "SAve_QR_Code_Received";
                ImageBase64: Text;
            begin
                Clear(CustomerName);
                Clear(CityName);
                Clear(CountyName);
 
                if CustomerRec.Get("Bill-to Customer No.") then
                    CustomerName := CustomerRec.Name;
                CityName := CustomerRec.City;
                CountyName := CustomerRec.County;
 
                TotalSubtotal := 0;
                TotalDiscount := 0;
                TotalTax := 0;
                TotalNet := 0;
 
                SalesInvoiceLine.SetRange("Document No.", "No.");
                if SalesInvoiceLine.FindSet() then begin
                    repeat
                        TotalSubtotal += SalesInvoiceLine."Quantity (Base)" * SalesInvoiceLine."Unit Price";
                        TotalDiscount += SalesInvoiceLine."Line Discount Amount";
                        TotalTax += ((SalesInvoiceLine."Quantity (Base)" * SalesInvoiceLine."Unit Price") - SalesInvoiceLine."Line Discount Amount") * (SalesInvoiceLine."VAT %" / 100);
                    until SalesInvoiceLine.Next() = 0;
                end;
                TotalNet := TotalSubtotal + TotalTax - TotalDiscount;
 
                QRTable.SetRange("Invoice_NO", "No.");
                if QRTable.FindSet() then begin
                    QRCodeText := QRTable."QR_Code_JO";
                    ImageBase64 := ConvertTextToImage(QRCodeText);
                    QRCodeText := 'data:image/png;base64,' + ImageBase64; // إضافة نوع الصورة ونقلها كـ base64
                end else begin
                    QRCodeText := '';
                end;
            end;
        }
    }
 
    local procedure ConvertTextToImage(Text: Text): Text
    var
        Base64Convert: Codeunit "Base64 Convert";
        TempBlob: Codeunit "Temp Blob";
        OutStream: OutStream;
        InStream: InStream;
        ImageBase64: Text;
    begin
        TempBlob.CreateOutStream(OutStream);
        OutStream.WriteText(Text);
        TempBlob.CreateInStream(InStream);
        ImageBase64 := Base64Convert.ToBase64(InStream);
        exit(ImageBase64);
    end;
 
    var
        CustomerRec: Record Customer;
 
        CustomerName: Text[100];
        CityName: Text[100];
        CountyName: Text[100];
        TotalDiscount: Decimal;
        TotalTax: Decimal;
        TotalSubtotal: Decimal;
        TotalNet: Decimal;
        QRCodeText: Text[1000];
}
I have the same question (0)
  • Suggested answer
    Ramiz Profile Picture
    628 on at
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,803 Super User 2026 Season 1 on at
     
    I think you need to use this code in your expression:
    System.Convert.FromBase64String(QR_Code)
    if this not working i think you need to remove the 'data:image/png;base64,' from the code !
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • Verified answer
    Jun Wang Profile Picture
    8,216 Moderator on at
    here is a video for reference
     
  • Verified answer
    YUN ZHU Profile Picture
    100,787 Super User 2026 Season 1 on at
  • Verified answer
    Suresh Kulla Profile Picture
    50,278 Super User 2026 Season 1 on at
    You can create a Blob using the text and then use the blob like in regular sales reports to show it or Look at report  6625 or 6626 you can use Barcode Font Provider 2D to create QR Code, if you are on the older version then let us know what version you are on 
     
    In BC20 you can also use the below code
     
     local procedure CreateQRCode(QRCodeInput: Text; var TempBLOB: Codeunit "Temp Blob")
        var
            EInvoiceObjectFactory: Codeunit "E-Invoice Object Factory";
        begin
            Clear(TempBLOB);
            EInvoiceObjectFactory.GetBarCodeBlob(QRCodeInput, TempBLOB);
        end;
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,909 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,145 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 974

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans