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

Notifications

Announcements

No record found.

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
    597 on at
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,436 Super User 2025 Season 2 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,202 Super User 2025 Season 2 on at
    here is a video for reference
     
  • Verified answer
    YUN ZHU Profile Picture
    95,729 Super User 2025 Season 2 on at
  • Verified answer
    Suresh Kulla Profile Picture
    50,245 Super User 2025 Season 2 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,135

#2
YUN ZHU Profile Picture

YUN ZHU 733 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 612

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans