AutoIt Requires Chilkat v11.7.0+
AutoIt
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 AutoIt Downloads
Local $bSuccess = 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.
$oSbCard = ObjCreate("Chilkat.StringBuilder")
$oSbCard.AppendLine("BEGIN:VCARD",True)
$oSbCard.AppendLine("VERSION:3.0",True)
$oSbCard.AppendLine("N:Smith;Alex;;;",True)
$oSbCard.AppendLine("FN:Alex Smith",True)
$oSbCard.AppendLine("ORG:Example Company",True)
$oSbCard.AppendLine("TITLE:Sales Manager",True)
$oSbCard.AppendLine("TEL;TYPE=CELL:+1-555-0100",True)
$oSbCard.AppendLine("EMAIL:alex.smith@example.com",True)
$oSbCard.AppendLine("URL:https://www.example.com",True)
$oSbCard.AppendLine("END:VCARD",True)
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateSb("payload.text",$oSbCard)
$oJson.UpdateInt("render.moduleSize",6)
$oJson.UpdateString("output.path","qa_output/qr_vcard.png")
$oJson.UpdateBool("output.overwrite",True)
$oJson.UpdateString("output.return","none")
$oFmt = ObjCreate("Chilkat.Formats")
$oJsonOut = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oFmt.QrCode("generate",$oJson,$oJsonOut)
If ($bSuccess = False) Then
ConsoleWrite($oFmt.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("vCard length: " & $oSbCard.Length & @CRLF)
ConsoleWrite("QR version: " & $oJsonOut.IntOf("symbols[0].selectedEncoding.version") & @CRLF)
ConsoleWrite("modules: " & $oJsonOut.IntOf("symbols[0].dimensions.modulesWide") & " x " & $oJsonOut.IntOf("symbols[0].dimensions.modulesHigh") & @CRLF)
ConsoleWrite("image: " & $oJsonOut.IntOf("outputs[0].width") & " x " & $oJsonOut.IntOf("outputs[0].height") & " pixels" & @CRLF)
; 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