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

Community site session details

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

QR Code in Business Central generates with extra spaces when encoding Base64 string

(1) ShareShare
ReportReport
Posted on by 221

Hi everyone,

 

I’m generating a QR code in Business Central using a Base64-encoded TLV string.

 

When I save the Base64 value in a field (Text type) it looks fine, for example:
ARBDUk9OVVMgVVNBLCBJbmMuAg8zOTk5OTk5OTk5MDAwMDMDEzIwMjUtMTAtMDZUMTI6MzQ6MjYEAzExNQUCMTUGLGlPbW1jeXFLVDNacUtKdmtHeXJ5TDJJMjRoZ0xQTkE5YTN2Vmo1NnNlYnM9B2BNRVVDSVFEZ1VZbkwvSXU3VXRGZmVYU3grd1c1TWVCd3VZWmNYMThJcTQwUUJ4UmJYZ0lnRW1DcHI4SjlmWEJLWXhFT0ZRQ2kyL1dOa3ZqaHdmckNreGJOTm0za3hCOD0IWDBWMBAGByqGSM49AgEGBSuBBAAKA0IABEl0eQuQYGlPgM1c0f/9w7Qu7m+btzmGMFFWuJOMPhqitKtnFTfBDX12GScv+14ddfJqG5ITqkJDVc7NEhnq+c0=

But when the QR code is generated and printed, the encoded text in the QR includes extra white spaces, for example:
ARBDUk9OVVMgVVNBLCBJbmMuAg8zOTk5OTk5OTk5MDAwMDMDEzIwMjUtMTAtMDZUMTI6MzQ6MjYEAzExNQUCMTUGLGlPbW1jeXFLVDNacUtKdmtHeXJ5TDJJMjRoZ0xQTkE5YTN2Vmo1NnNlYnM9B2BNRVVDSVFEZ1VZbkwvSXU3VXRGZmVYU3grd1c1TWVCd3VZWmNYMThJcTQwUUJ4UmJYZ0lnRW1DcHI4SjlmWEJLWXhFT0ZRQ2kyL1dOa3ZqaHdmckNreGJOTm0za3hCOD0IWDBWMBAGByqGSM49AgEGBSuBBAAKA0IABEl0eQuQYGlPgM1c0f/9w7Qu7m btzmGMFFWuJOMPhqitKtnFTfBDX12GScv 14ddfJqG5ITqkJDVc7NEhnq c0=

As you can see, extra spaces appear randomly inside the Base64 text (e.g. after 7m, after Scv, etc.), which causes QR code verification to fail.How can I safely encode and render the QR without breaking the Base64 format

I have the same question (0)
  • Suggested answer
    OussamaSabbouh Profile Picture
    143 on at
    QR Code in Business Central generates with extra spaces when encoding Base64 string

    Hello,

    The best way to avoid these issues entirely is to not send the Base64 string to the report at all. Instead, generate the QR code image directly in AL code and pass the image itself to the report via a BLOB field.

    This method bypasses any text formatting or wrapping issues because the report is only responsible for displaying a pre-rendered image.

    Here is the workflow:

    1. Generate QR Image in AL: o convert your TLV string directly into an image (e.g., a PNG byte array).

    2. Store in a BLOB: Load this byte array into an OutStream connected to a BLOB field on a temporary table.

    3. Add BLOB to Dataset: Add this BLOB field to your report's dataset.

    4. Display in Report Layout:

      • In your RDLC or Word layout, add an Image control.

      • Set the image's source to Database.

      • Set its value to be the BLOB field from your dataset.

      • Set the MIMEType to image/png (or whichever format you generated).

    This approach is more reliable because the report layout engine is simply rendering a picture and doesn't get a chance to "fix" the long text string.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 4,304

#2
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,045

#3
Sumit Singh Profile Picture

Sumit Singh 2,970

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans