Classic ASP Requires Chilkat v11.7.0+
Classic ASP
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 Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
set json = Server.CreateObject("Chilkat.JsonObject")
success = json.UpdateString("payload.text","https://www.chilkatsoft.com/order/12345")
success = json.UpdateInt("render.moduleSize",6)
' The caption. It need not be the same as the text in the QR code.
success = json.UpdateBool("render.text.enabled",1)
success = json.UpdateString("render.text.value","ORDER 12345")
' position is "below" (the default) or "above". alignment is "center" (the default), "left" or "right".
success = json.UpdateString("render.text.position","below")
' Each dot of the caption's font is drawn this many pixels wide.
success = json.UpdateInt("render.text.scale",3)
success = json.UpdateString("output.path","qa_output/qr_caption.png")
success = json.UpdateBool("output.overwrite",1)
success = json.UpdateString("output.return","none")
set fmt = Server.CreateObject("Chilkat.Formats")
set jsonOut = Server.CreateObject("Chilkat.JsonObject")
success = fmt.QrCode("generate",json,jsonOut)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( fmt.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "caption: " & jsonOut.StringOf("measurements[0].text")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "caption scale: " & jsonOut.IntOf("measurements[0].textScale")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "height added for the caption: " & jsonOut.IntOf("measurements[0].textBandPx") & " pixels") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "image: " & jsonOut.IntOf("measurements[0].canvasWidth") & " x " & jsonOut.IntOf("measurements[0].canvasHeight") & " pixels") & "</pre>"
' 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
%>
</body>
</html>