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 :
Finance | Project Operations, Human Resources, ...
Unanswered

How to generate QR CODE with Arabic characters

(0) ShareShare
ReportReport
Posted on by 3,089

Hello Experts,

I have generated the QR within the Sales Invoice report but the problem is while I am trying to generate the same with Arabic characters it wont appear.

Following are the code.

    Microsoft.Dynamics.QRCode.Encoder   qrCode;
    System.String                       netString;
    str                                 tempFileName;
    System.Drawing.Bitmap               netBitmap;
   
    FileIOPermission                    perm;
    BinData                             binData;
    container                           imageContainer;
    
    ;


    netString = _QRDataString;//"ahmed muhammad alam and mohammad el sayed are the best brothers in bakheet along with Mr. Kashif choudry";
    qrCode = new Microsoft.Dynamics.QRCode.Encoder();
    netBitmap = qrCode.Encode(netString); //encode the string as Bitmap can be used already

    tempFileName = qrCode.GetTempFile(netString); //to get the QR temporary file

    perm = new FileIOPermission(tempFileName,'r');
    perm.assert();
    binData = new binData();
    binData.loadFile(tempFileName);
    imageContainer = binData.getData(); //get the QR code image put inside container so can be stored inside database for storing or reporting purpose


    CodeAccessPermission::revertAssert();
    return binData.getData();

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,025 Super User 2025 Season 2 on at

    Hi Ahmed,

    You can try another encoder for QR codes: www.codeproject.com/.../Basic-with-QR-Code-using-Zxing-Library

  • Ahmed Muhammad Alam Profile Picture
    3,089 on at

    Dear Andre,

    I have tried to download the Zxing project but unable to configure it in my PC. Can you please provide the DLL so I can use it in AX 2012.

    Regards,

  • Ahmed Muhammad Alam Profile Picture
    3,089 on at

    Hello,

    I have tried the project with ZXING.

    and created a form for test, but unfortunately upon scan the value is ???? ???? ????? rather than ARABIC.

    Regards,

  • André Arnaud de Calavon Profile Picture
    301,025 Super User 2025 Season 2 on at

    Hi Ahmed,

    I never used ZXING myself in combination with Dynamics AX. It was worth a try.

  • Ahmed Muhammad Alam Profile Picture
    3,089 on at

    Dear Experts,

    I have done the following procedure.

    1- VISUAL STUDIO 2010

    ---------------------------

    Create a class library to convert the string into QR Code with the help of ZXING.

    public Bitmap EncodeQR(string _qrValue)

           {

               ZXing.QrCode.QrCodeEncodingOptions _options = new ZXing.QrCode.QrCodeEncodingOptions();

               _options = new ZXing.QrCode.QrCodeEncodingOptions()

               {

                   DisableECI = true,

                   CharacterSet = "UTF-8",

                   Width = 250,

                   Height = 250,

               };

               var qrCode = new ZXing.BarcodeWriter();

               qrCode.Format = ZXing.BarcodeFormat.QR_CODE;

               qrCode.Options = _options;

               var _result = new Bitmap(qrCode.Write(_qrValue.ToString()));

               return _result;

           }

    2- MS Dynamics AX 2012 R2 CU7

    -------------------------------------

    - Export the VS project to AOT

    - Copy the dll file to the client

    - Add the dll to the AOT reference

    Create a job to call the dll with string.

    public static container Generate_QRZXING(str 1000    _QRDataString)

    {

       QRCoder.Encoder                             _qrEncoder = new QRCoder.Encoder();

       System.Drawing.Bitmap                       _result;

       str 1000                                    _TempFileName;

       real                                        _value;

       BinData                                     _binData;

       Microsoft.Dynamics.QRCode.Encoder           qrCode = new Microsoft.Dynamics.QRCode.Encoder();

       FileIOPermission                            perm;

       ;

       _result = _qrEncoder.EncodeQR(_QRDataString); /////////////////////// ERROR HERE /////////////////////////////////

       _TempFileName = qrCode.GetTempFile(_QRDataString);

        perm = new FileIOPermission(_TempFileName,'r');

        perm.assert();

       _binData = new BinData();

       _binData.loadFile(_QRDataString);

       return _binData.getData();

    }

    I am unable to understand when the code reach to "ERROR HERE". System didn't show any error message or nothing just close the process.

    While I have created another VS2010 form based project to test the dll and it's working perfectly fine.

  • Abdulaziz Albloshi Profile Picture
    365 on at

    Hi Alam

    I have used QRCoder reference from the standard available references.

    below is a brief explanation:

    1.  using QRCoder; //add this on top of the class

    2. use some code as below:

      System.Drawing.Bitmap result;

           System.String totalString;

           totalString="النص باللغة العربية ";

           QRCodeGenerator.ECCLevel eccLevel;

           QRCodeGenerator qrGenerator = new QRCodeGenerator();

           QRCodeData qrCodeData = qrGenerator.CreateQrCode(totalString, eccLevel);

           QRCode qrCode = new QRCode(qrCodeData);

           result = qrCode.GetGraphic(20);

    3. save result and it will have a QR code image with arabic text

    please approach me on linkedin if you have further queries.

  • Rani alnoor Profile Picture
    10 on at

    Hi Alam

    Did you get the solution?

  • Abdulaziz Albloshi Profile Picture
    365 on at

    Hi Rani, try my provided code. I have successfully deployed QR code with arabic chars on my sales invoices. BTW That was in D365FO.

  • Rani alnoor Profile Picture
    10 on at

    Can I use it on ax2012?

  • Abdulaziz Albloshi Profile Picture
    365 on at

    I didn't try on AX2012, but surely there will be a way to do that.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans