PowerBuilder Requires Chilkat v11.7.0+
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_Json
oleobject loo_Fmt
oleobject loo_JsonOut
oleobject loo_Json2
li_Success = 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
if li_rc < 0 then
destroy loo_Json
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Json.UpdateString("symbology","qr")
loo_Json.UpdateString("payload.text","https://www.chilkatsoft.com/")
loo_Json.UpdateString("output.path","qa_output/qr_from_barcode.png")
loo_Json.UpdateBool("output.overwrite",1)
loo_Json.UpdateString("output.return","none")
loo_Fmt = create oleobject
li_rc = loo_Fmt.ConnectToNewObject("Chilkat.Formats")
loo_JsonOut = create oleobject
li_rc = loo_JsonOut.ConnectToNewObject("Chilkat.JsonObject")
li_Success = loo_Fmt.Barcode("generate",loo_Json,loo_JsonOut)
if li_Success = 0 then
Write-Debug loo_Fmt.LastErrorText
destroy loo_Json
destroy loo_Fmt
destroy loo_JsonOut
return
end if
Write-Debug "symbology: " + loo_JsonOut.StringOf("symbols[0].symbology")
Write-Debug "QR version: " + string(loo_JsonOut.IntOf("symbols[0].selectedEncoding.version"))
Write-Debug "image: " + string(loo_JsonOut.IntOf("outputs[0].width")) + " x " + string(loo_JsonOut.IntOf("outputs[0].height")) + " pixels"
// The image written to qa_output/qr_from_barcode.png:
//
// Barcode requires the symbology. QrCode does not.
loo_Json2 = create oleobject
li_rc = loo_Json2.ConnectToNewObject("Chilkat.JsonObject")
loo_Json2.UpdateString("payload.text","https://www.chilkatsoft.com/")
li_Success = loo_Fmt.Barcode("generate",loo_Json2,loo_JsonOut)
if li_Success = 0 then
Write-Debug "without a symbology: " + loo_JsonOut.StringOf("errors[0].code") + " at " + loo_JsonOut.StringOf("errors[0].path")
end if
// Sample output:
// symbology: qr
// QR version: 3
// image: 148 x 148 pixels
// without a symbology: missingOption at /symbology
destroy loo_Json
destroy loo_Fmt
destroy loo_JsonOut
destroy loo_Json2