Xojo Plugin Requires Chilkat v11.7.0+
Xojo Plugin
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 Xojo Plugin Downloads
Dim success As Boolean
success = False
// 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.
Dim sbCard As New Chilkat.StringBuilder
success = sbCard.AppendLine("BEGIN:VCARD",True)
success = sbCard.AppendLine("VERSION:3.0",True)
success = sbCard.AppendLine("N:Smith;Alex;;;",True)
success = sbCard.AppendLine("FN:Alex Smith",True)
success = sbCard.AppendLine("ORG:Example Company",True)
success = sbCard.AppendLine("TITLE:Sales Manager",True)
success = sbCard.AppendLine("TEL;TYPE=CELL:+1-555-0100",True)
success = sbCard.AppendLine("EMAIL:alex.smith@example.com",True)
success = sbCard.AppendLine("URL:https://www.example.com",True)
success = sbCard.AppendLine("END:VCARD",True)
Dim json As New Chilkat.JsonObject
success = json.UpdateSb("payload.text",sbCard)
success = json.UpdateInt("render.moduleSize",6)
success = json.UpdateString("output.path","qa_output/qr_vcard.png")
success = json.UpdateBool("output.overwrite",True)
success = json.UpdateString("output.return","none")
Dim fmt As New Chilkat.Formats
Dim jsonOut As New Chilkat.JsonObject
success = fmt.QrCode("generate",json,jsonOut)
If (success = False) Then
System.DebugLog(fmt.LastErrorText)
Return
End If
System.DebugLog("vCard length: " + Str(sbCard.Length))
System.DebugLog("QR version: " + Str(jsonOut.IntOf("symbols[0].selectedEncoding.version")))
System.DebugLog("modules: " + Str(jsonOut.IntOf("symbols[0].dimensions.modulesWide")) + " x " + Str(jsonOut.IntOf("symbols[0].dimensions.modulesHigh")))
System.DebugLog("image: " + Str(jsonOut.IntOf("outputs[0].width")) + " x " + Str(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