Sample code for 30+ languages & platforms
Delphi DLL Requires Chilkat v11.7.0+

Generate a QR Code with the Barcode Method

See more QR Code Examples

Demonstrates the Barcode method, which is the general form of QrCode: the request names the symbology, and everything else is the same. QrCode is Barcode with the symbology already set to qr, and identical requests to the two methods give identical results. A program that will produce more than one kind of barcode can use Barcode for all of them.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
json: HCkJsonObject;
fmt: HCkFormats;
jsonOut: HCkJsonObject;
json2: HCkJsonObject;

begin
success := False;

//  This example requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

json := CkJsonObject_Create();
CkJsonObject_UpdateString(json,'symbology','qr');
CkJsonObject_UpdateString(json,'payload.text','https://www.chilkatsoft.com/');
CkJsonObject_UpdateString(json,'output.path','qa_output/qr_from_barcode.png');
CkJsonObject_UpdateBool(json,'output.overwrite',True);
CkJsonObject_UpdateString(json,'output.return','none');

fmt := CkFormats_Create();
jsonOut := CkJsonObject_Create();
success := CkFormats_Barcode(fmt,'generate',json,jsonOut);
if (success = False) then
  begin
    Memo1.Lines.Add(CkFormats__lastErrorText(fmt));
    Exit;
  end;

Memo1.Lines.Add('symbology: ' + CkJsonObject__stringOf(jsonOut,'symbols[0].symbology'));
Memo1.Lines.Add('QR version: ' + IntToStr(CkJsonObject_IntOf(jsonOut,'symbols[0].selectedEncoding.version')));
Memo1.Lines.Add('image: ' + IntToStr(CkJsonObject_IntOf(jsonOut,'outputs[0].width')) + ' x ' + IntToStr(CkJsonObject_IntOf(jsonOut,'outputs[0].height')) + ' pixels');

//  The image written to qa_output/qr_from_barcode.png:

//  image

//  Barcode requires the symbology.  QrCode does not.
json2 := CkJsonObject_Create();
CkJsonObject_UpdateString(json2,'payload.text','https://www.chilkatsoft.com/');
success := CkFormats_Barcode(fmt,'generate',json2,jsonOut);
if (success = False) then
  begin
    Memo1.Lines.Add('without a symbology: ' + CkJsonObject__stringOf(jsonOut,'errors[0].code') + ' at ' + CkJsonObject__stringOf(jsonOut,'errors[0].path'));
  end;

//  Sample output:

//  symbology: qr
//  QR version: 3
//  image: 148 x 148 pixels
//  without a symbology: missingOption at /symbology

CkJsonObject_Dispose(json);
CkFormats_Dispose(fmt);
CkJsonObject_Dispose(jsonOut);
CkJsonObject_Dispose(json2);