PowerBuilder Requires Chilkat v11.7.0+
PowerBuilder
Create a vCard (Contact) QR Code
See more QR Code Examples
Demonstrates a QR code that adds a contact to a phone when scanned. The text is a vCard, the standard format for contact details: lines between BEGIN:VCARD and END:VCARD, each ending with CRLF. A vCard is fairly long, so the symbol is larger than one holding a web address. Leave out the fields that are not needed to keep it small.Chilkat PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_SbCard
oleobject loo_Json
oleobject loo_Fmt
oleobject loo_JsonOut
li_Success = 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// The second argument of AppendLine is cktrue to end each line with CRLF.
loo_SbCard = create oleobject
li_rc = loo_SbCard.ConnectToNewObject("Chilkat.StringBuilder")
if li_rc < 0 then
destroy loo_SbCard
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_SbCard.AppendLine("BEGIN:VCARD",1)
loo_SbCard.AppendLine("VERSION:3.0",1)
loo_SbCard.AppendLine("N:Smith;Alex;;;",1)
loo_SbCard.AppendLine("FN:Alex Smith",1)
loo_SbCard.AppendLine("ORG:Example Company",1)
loo_SbCard.AppendLine("TITLE:Sales Manager",1)
loo_SbCard.AppendLine("TEL;TYPE=CELL:+1-555-0100",1)
loo_SbCard.AppendLine("EMAIL:alex.smith@example.com",1)
loo_SbCard.AppendLine("URL:https://www.example.com",1)
loo_SbCard.AppendLine("END:VCARD",1)
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Json.UpdateSb("payload.text",loo_SbCard)
loo_Json.UpdateInt("render.moduleSize",6)
loo_Json.UpdateString("output.path","qa_output/qr_vcard.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.QrCode("generate",loo_Json,loo_JsonOut)
if li_Success = 0 then
Write-Debug loo_Fmt.LastErrorText
destroy loo_SbCard
destroy loo_Json
destroy loo_Fmt
destroy loo_JsonOut
return
end if
Write-Debug "vCard length: " + string(loo_SbCard.Length)
Write-Debug "QR version: " + string(loo_JsonOut.IntOf("symbols[0].selectedEncoding.version"))
Write-Debug "modules: " + string(loo_JsonOut.IntOf("symbols[0].dimensions.modulesWide")) + " x " + string(loo_JsonOut.IntOf("symbols[0].dimensions.modulesHigh"))
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_vcard.png:
//
// Sample output:
// vCard length: 197
// QR version: 10
// modules: 57 x 57
// image: 390 x 390 pixels
destroy loo_SbCard
destroy loo_Json
destroy loo_Fmt
destroy loo_JsonOut