Image-Charts: QR Code, Create

Image-Charts: QR Code, 生成

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.

Auto Step icon
Configs for this Auto Step
StrConfA1
A1: Set String to Encode *#{EL}
StrConfB1
B1: Set File Name of QR Code in PNG to save as#{EL}
SelectConfB2
B2: Select FILE DATA that stores QR Code in PNG (append) *
StrConfC1
C1: If other than “150×150”, Set Image Size#{EL}
Script (click to open)
// GraalJS Script (engine type: 3)

//////// 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

warning Freely modifiable JavaScript (ECMAScript) code. No warranty of any kind.
(Installing Addon Auto-Steps are available only on the 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

Appendix

How to delete Image-Charts Watermarks (common to all Image-Charts)

See Also

%d bloggers like this: