Delphi ActiveX Requires Chilkat v11.7.0+
Delphi ActiveX
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 ActiveX Downloads
var
success: Integer;
json: TChilkatJsonObject;
fmt: TChilkatFormats;
jsonOut: TChilkatJsonObject;
json2: TChilkatJsonObject;
begin
success := 0;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
json := TChilkatJsonObject.Create(Self);
json.UpdateString('symbology','qr');
json.UpdateString('payload.text','https://www.chilkatsoft.com/');
json.UpdateString('output.path','qa_output/qr_from_barcode.png');
json.UpdateBool('output.overwrite',1);
json.UpdateString('output.return','none');
fmt := TChilkatFormats.Create(Self);
jsonOut := TChilkatJsonObject.Create(Self);
success := fmt.Barcode('generate',json.ControlInterface,jsonOut.ControlInterface);
if (success = 0) then
begin
Memo1.Lines.Add(fmt.LastErrorText);
Exit;
end;
Memo1.Lines.Add('symbology: ' + jsonOut.StringOf('symbols[0].symbology'));
Memo1.Lines.Add('QR version: ' + IntToStr(jsonOut.IntOf('symbols[0].selectedEncoding.version')));
Memo1.Lines.Add('image: ' + IntToStr(jsonOut.IntOf('outputs[0].width')) + ' x ' + IntToStr(jsonOut.IntOf('outputs[0].height')) + ' pixels');
// The image written to qa_output/qr_from_barcode.png:
//
// Barcode requires the symbology. QrCode does not.
json2 := TChilkatJsonObject.Create(Self);
json2.UpdateString('payload.text','https://www.chilkatsoft.com/');
success := fmt.Barcode('generate',json2.ControlInterface,jsonOut.ControlInterface);
if (success = 0) then
begin
Memo1.Lines.Add('without a symbology: ' + jsonOut.StringOf('errors[0].code') + ' at ' + jsonOut.StringOf('errors[0].path'));
end;
// Sample output:
// symbology: qr
// QR version: 3
// image: 148 x 148 pixels
// without a symbology: missingOption at /symbology