Visual FoxPro Requires Chilkat v11.7.0+
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
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.
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("payload.text","https://www.chilkatsoft.com/order/12345")
loJson.UpdateInt("render.moduleSize",6)
* The caption. It need not be the same as the text in the QR code.
loJson.UpdateBool("render.text.enabled",1)
loJson.UpdateString("render.text.value","ORDER 12345")
* position is "below" (the default) or "above". alignment is "center" (the default), "left" or "right".
loJson.UpdateString("render.text.position","below")
* Each dot of the caption's font is drawn this many pixels wide.
loJson.UpdateInt("render.text.scale",3)
loJson.UpdateString("output.path","qa_output/qr_caption.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 loJson
RELEASE loFmt
RELEASE loJsonOut
CANCEL
ENDIF
? "caption: " + loJsonOut.StringOf("measurements[0].text")
? "caption scale: " + STR(loJsonOut.IntOf("measurements[0].textScale"))
? "height added for the caption: " + STR(loJsonOut.IntOf("measurements[0].textBandPx")) + " pixels"
? "image: " + STR(loJsonOut.IntOf("measurements[0].canvasWidth")) + " x " + STR(loJsonOut.IntOf("measurements[0].canvasHeight")) + " pixels"
* 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
RELEASE loJson
RELEASE loFmt
RELEASE loJsonOut