AutoIt Requires Chilkat v11.7.0+
AutoIt
QR Code with a Text Caption
See more QR Code Examples
Demonstrates printing a line of text under a QR code, such as the order number or the address the code holds, so that a person can read it too. render.text turns the caption on and gives its value, which is printable ASCII and is drawn in a built-in font that needs no font files. The caption can go above or below the symbol, be aligned left, center or right, and be scaled.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("payload.text","https://www.chilkatsoft.com/order/12345")
$oJson.UpdateInt("render.moduleSize",6)
; The caption. It need not be the same as the text in the QR code.
$oJson.UpdateBool("render.text.enabled",True)
$oJson.UpdateString("render.text.value","ORDER 12345")
; position is "below" (the default) or "above". alignment is "center" (the default), "left" or "right".
$oJson.UpdateString("render.text.position","below")
; Each dot of the caption's font is drawn this many pixels wide.
$oJson.UpdateInt("render.text.scale",3)
$oJson.UpdateString("output.path","qa_output/qr_caption.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("caption: " & $oJsonOut.StringOf("measurements[0].text") & @CRLF)
ConsoleWrite("caption scale: " & $oJsonOut.IntOf("measurements[0].textScale") & @CRLF)
ConsoleWrite("height added for the caption: " & $oJsonOut.IntOf("measurements[0].textBandPx") & " pixels" & @CRLF)
ConsoleWrite("image: " & $oJsonOut.IntOf("measurements[0].canvasWidth") & " x " & $oJsonOut.IntOf("measurements[0].canvasHeight") & " pixels" & @CRLF)
; The image written to qa_output/qr_caption.png:
;
; Sample output:
; caption: ORDER 12345
; caption scale: 3
; height added for the caption: 21 pixels
; image: 222 x 243 pixels