Image-Charts: QR Code, Create
Creates a QR Code using the Image-Chart QRCode web service generation. It is possible to encode any string data to the QR code. The QR Code image will be output in png format.
Configs
  • A1: Set String to Encode *#{EL}
  • B1: Set File Name of QR Code in PNG to save as#{EL}
  • B2: Select FILE DATA that stores QR Code in PNG (append) *
  • C1: If other than “150×150”, Set Image Size#{EL}
Script (click to open)
// GraalJS Script (engine type: 2)

//////// START "main()" /////////////////////////////////////////////////////////////////

main();
function main(){ 

//// == Config Retrieving / 工程コンフィグの参照 ==
const strInput     = configs.get      ( "StrConfA1" );    /// REQUIRED
  if( strInput   === "" ){
    throw new Error( "\n AutomatedTask ConfigError:" +
                     " Config {A1} is empty \n" );
  }
let   strSaveas    = configs.get      ( "StrConfB1" );    // NotRequired
  if( strSaveas  === "" ){
    engine.log( " AutomatedTask ConfigWarning:" +
                " Config {B1:Saveas} is empty" );
  }
const filesPocket  = configs.getObject( "SelectConfB2" ); /// REQUIRED
let   strSize      = configs.get      ( "StrConfC1" );    // NotRequired
  if( strSize    === "" ){
      strSize      = "150x150";
  }


//// == Data Retrieving / ワークフローデータの参照 ==
let filesAttached = engine.findData( filesPocket ); // java.util.ArrayList
if( filesAttached === null ) {
  engine.log( " AutomatedTask FilesArray {B2}: (empty)" );
  filesAttached = new java.util.ArrayList();
}else{
  engine.log( " AutomatedTask FilesArray {B2}: " +
              filesAttached.size() + " files" );
}


//// == Calculating / 演算 ==
if( strSaveas === "" ){
  strSaveas   = processInstance.getProcessInstanceId() + ".png";
}

/// Image-charts developer hub > QR Codes
/// https://documentation.image-charts.com/qr-codes/
// request1, prepare
let request1Uri = "https://image-charts.com/chart";
let request1    = httpClient.begin(); // HttpRequestWrapper
    request1    = request1.queryParam( "chs",  strSize );
    request1    = request1.queryParam( "cht",  "qr" );
    request1    = request1.queryParam( "chl",  strInput );
    request1    = request1.queryParam( "choe", "UTF-8" );
// request1, try
const response1     = request1.post( request1Uri ); // HttpResponseWrapper
engine.log( " AutomatedTask ApiRequest1 Start: " + request1Uri );
const response1Code = response1.getStatusCode() + "";
const response1Body = response1.getResponseAsString() + "";
engine.log( " AutomatedTask ApiResponse Status: " + response1Code );
if( response1Code !== "200"){
  throw new Error( "\n AutomatedTask UnexpectedResponseError: " +
                    response1Code + "\n" + response1Body + "\n" );
}
// response1, parse
const fileTmp = new com.questetra.bpms.core.event.scripttask.NewQfile(
                 strSaveas, response1.getContentType(), response1.getResponse()
                );
filesAttached.add( fileTmp );


//// == Data Updating / ワークフローデータへの代入 ==
engine.setData( filesPocket,    filesAttached );


} //////// END "main()" /////////////////////////////////////////////////////////////////


/*
Notes:
- "{pid}.png", if not specify a file name.
- QR codes support 4 levels of error correction to enable recovery of missing, misread, or obscured data.
    - The QR code generated by this Addon can recover up to 7% data loss.
Notes-ja:
- ファイル名を指定しない場合、 {pid}.png となります。
- QRコードは、4つのレベルのエラー訂正をサポートしています(欠落、誤読、または不明瞭なデータの回復)
    - このアドオンで生成されるQRコードは、最大7%のデータ損失を回復できます。

APPENDIX-en
- To remove Image-Charts watermark (Common to Image-Charts)
    - https://documentation.image-charts.com/enterprise/#remove-image-charts-watermark-by-signing-urls
APPENDIX-ja
- Image-Charts Watermark(透かし)の削除方法(Image-Charts共通)
    - https://documentation.image-charts.com/enterprise/#remove-image-charts-watermark-by-signing-urls
*/

Download

2021-04-22 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/image-charts-qr-code-create-2021/
The Addon-import feature is available with Professional edition.

Notes

  • If you do not specify a file name it will be {pid}.png.
  • QR codes support 4 levels of error correction to enable recovery of missing, misread or obscured data.
    • The QR code generated by this Addon can recover up to 7% data loss.

Capture

Creates a QR Code using the Image-Chart QRCode web service generation. It is possible to encode any string data to the QR code. The QR Code image will be output in png format.
Creates a QR Code using the Image-Chart QRCode web service generation. It is possible to encode any string data to the QR code. The QR Code image will be output in png format.

Appendix

See also

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: