Classic ASP Requires Chilkat v11.7.0+
Classic ASP
QR Code with Binary Data
See more QR Code Examples
Demonstrates a QR code that holds arbitrary bytes rather than text. The payload type is binary and the bytes are given as base64 in payload.base64. Any byte value may be used, including zero. Keep in mind that many phone camera apps expect text, so binary payloads are for readers that you control.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.
' The bytes to encode. Here they come from hex, but they could be loaded from a file with LoadFile.
set bd = Server.CreateObject("Chilkat.BinData")
success = bd.AppendEncoded("000102030405FF00FE4368696C6B6174","hex")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( bd.LastErrorText) & "</pre>"
Response.End
End If
set json = Server.CreateObject("Chilkat.JsonObject")
success = json.UpdateString("payload.type","binary")
success = json.UpdateString("payload.base64",bd.GetEncoded("base64"))
success = json.UpdateString("output.path","qa_output/qr_binary.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( "bytes given: " & bd.NumBytes) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "bytes encoded: " & jsonOut.IntOf("symbols[0].payloadBytes")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "mode: " & jsonOut.StringOf("symbols[0].selectedEncoding.mode")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "QR version: " & jsonOut.IntOf("symbols[0].selectedEncoding.version")) & "</pre>"
' The image written to qa_output/qr_binary.png:
'
' Sample output:
' bytes given: 16
' bytes encoded: 16
' mode: byte
' QR version: 2
%>
</body>
</html>