Home computer programming, dynamics ax print qr code on ax 2012/2009 report
computer programmingdynamics ax

print qr code on ax 2012/2009 report

I will provide the content by screen shoot

private void disclaimer()
{
    //created by ronny
    //20210204 11:08
    //and will be published on official websites
}

public class ReportRun extends ObjectRun
{
}

public Container GenerateQRCode(
    str param)
{
    FileIOPermission    perm;
    BinData             binData;
    container           imageContainer;
    str 5000             tempFileName2;
    HpgCsFunction       _f = new HpgCsFunction();
    System.String       netString;
    Microsoft.Dynamics.QRCode.Encoder   qrCode;
    System.Drawing.Bitmap               netBitmap;

//you may modified netString here, 
    netString = strFmt("{\"DataType\":\"PackingSlip\", \"Id\":\"%1\", \"KeyCode\":\"%2\"}", param, _f.getLockKey(param)) ;
    qrCode = new Microsoft.Dynamics.QRCode.Encoder();
    netBitmap = qrCode.Encode(netString); //encode the string as Bitmap can be used already
    tempFileName2 = qrCode.GetTempFile(netString); //to get the QR temporary file

    perm = new FileIOPermission(tempFileName2,'r');
    perm.assert();
    binData = new binData();
    binData.loadFile(tempFileName2);
    imageContainer = binData.getData();
    System.IO.File::Delete(tempFileName2);
    CodeAccessPermission::revertAssert();

    return imageContainer;
}

 

this solution not only works on reports, it also works on ssrs report, the difference is, the return Container should be inserted to tmpTable Container Fields and the tmpTableContainerFields enable on the SSRS Reports

 

get the source code SharedProject_HpExPrintBarcode

Author

Ronny

Leave a Reply