DataFlex Requires Chilkat v11.7.0+
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Variant vJson
Handle hoJson
Handle hoFmt
Variant vJsonOut
Handle hoJsonOut
Variant vJson2
Handle hoJson2
String sTemp1
String sTemp2
Integer iTemp1
Integer iTemp2
Move False To iSuccess
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "symbology" "qr" To iSuccess
Get ComUpdateString Of hoJson "payload.text" "https://www.chilkatsoft.com/" To iSuccess
Get ComUpdateString Of hoJson "output.path" "qa_output/qr_from_barcode.png" To iSuccess
Get ComUpdateBool Of hoJson "output.overwrite" True To iSuccess
Get ComUpdateString Of hoJson "output.return" "none" To iSuccess
Get Create (RefClass(cComChilkatFormats)) To hoFmt
If (Not(IsComObjectCreated(hoFmt))) Begin
Send CreateComObject of hoFmt
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJsonOut
If (Not(IsComObjectCreated(hoJsonOut))) Begin
Send CreateComObject of hoJsonOut
End
Get pvComObject of hoJson to vJson
Get pvComObject of hoJsonOut to vJsonOut
Get ComBarcode Of hoFmt "generate" vJson vJsonOut To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFmt To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComStringOf Of hoJsonOut "symbols[0].symbology" To sTemp1
Showln "symbology: " sTemp1
Get ComIntOf Of hoJsonOut "symbols[0].selectedEncoding.version" To iTemp1
Showln "QR version: " iTemp1
Get ComIntOf Of hoJsonOut "outputs[0].width" To iTemp1
Get ComIntOf Of hoJsonOut "outputs[0].height" To iTemp2
Showln "image: " iTemp1 " x " iTemp2 " pixels"
// The image written to qa_output/qr_from_barcode.png:
//
// Barcode requires the symbology. QrCode does not.
Get Create (RefClass(cComChilkatJsonObject)) To hoJson2
If (Not(IsComObjectCreated(hoJson2))) Begin
Send CreateComObject of hoJson2
End
Get ComUpdateString Of hoJson2 "payload.text" "https://www.chilkatsoft.com/" To iSuccess
Get pvComObject of hoJson2 to vJson2
Get pvComObject of hoJsonOut to vJsonOut
Get ComBarcode Of hoFmt "generate" vJson2 vJsonOut To iSuccess
If (iSuccess = False) Begin
Get ComStringOf Of hoJsonOut "errors[0].code" To sTemp1
Get ComStringOf Of hoJsonOut "errors[0].path" To sTemp2
Showln "without a symbology: " sTemp1 " at " sTemp2
End
// Sample output:
// symbology: qr
// QR version: 3
// image: 148 x 148 pixels
// without a symbology: missingOption at /symbology
End_Procedure