Visual FoxPro Requires Chilkat v11.7.0+
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loSbCard
LOCAL loJson
LOCAL loFmt
LOCAL loJsonOut
lnSuccess = 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.
loSbCard = CreateObject('Chilkat.StringBuilder')
loSbCard.AppendLine("BEGIN:VCARD",1)
loSbCard.AppendLine("VERSION:3.0",1)
loSbCard.AppendLine("N:Smith;Alex;;;",1)
loSbCard.AppendLine("FN:Alex Smith",1)
loSbCard.AppendLine("ORG:Example Company",1)
loSbCard.AppendLine("TITLE:Sales Manager",1)
loSbCard.AppendLine("TEL;TYPE=CELL:+1-555-0100",1)
loSbCard.AppendLine("EMAIL:alex.smith@example.com",1)
loSbCard.AppendLine("URL:https://www.example.com",1)
loSbCard.AppendLine("END:VCARD",1)
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateSb("payload.text",loSbCard)
loJson.UpdateInt("render.moduleSize",6)
loJson.UpdateString("output.path","qa_output/qr_vcard.png")
loJson.UpdateBool("output.overwrite",1)
loJson.UpdateString("output.return","none")
loFmt = CreateObject('Chilkat.Formats')
loJsonOut = CreateObject('Chilkat.JsonObject')
lnSuccess = loFmt.QrCode("generate",loJson,loJsonOut)
IF (lnSuccess = 0) THEN
? loFmt.LastErrorText
RELEASE loSbCard
RELEASE loJson
RELEASE loFmt
RELEASE loJsonOut
CANCEL
ENDIF
? "vCard length: " + STR(loSbCard.Length)
? "QR version: " + STR(loJsonOut.IntOf("symbols[0].selectedEncoding.version"))
? "modules: " + STR(loJsonOut.IntOf("symbols[0].dimensions.modulesWide")) + " x " + STR(loJsonOut.IntOf("symbols[0].dimensions.modulesHigh"))
? "image: " + STR(loJsonOut.IntOf("outputs[0].width")) + " x " + STR(loJsonOut.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
RELEASE loSbCard
RELEASE loJson
RELEASE loFmt
RELEASE loJsonOut