Sample code for 30+ languages & platforms
Classic ASP Requires Chilkat v11.7.0+

Generate a QR Code PNG in Memory

See more QR Code Examples

Demonstrates getting a QR code image without writing a file. With no output options the result is a PNG returned as base64 in outputs[0].base64 of the response. The example decodes it into a BinData, which holds the bytes of the PNG to send in an HTTP response, store in a database, attach to an email, or save.

Chilkat Classic ASP Downloads

Classic ASP
<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/")
success = json.UpdateInt("render.moduleSize",6)

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( "format: " & jsonOut.StringOf("outputs[0].format")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "MIME type: " & jsonOut.StringOf("outputs[0].mimeType")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "image: " & jsonOut.IntOf("outputs[0].width") & " x " & jsonOut.IntOf("outputs[0].height") & " pixels") & "</pre>"

'  outputs[0].base64 is the PNG file, base64 encoded.
set bdPng = Server.CreateObject("Chilkat.BinData")
success = bdPng.AppendEncoded(jsonOut.StringOf("outputs[0].base64"),"base64")
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( bdPng.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "PNG bytes: " & bdPng.NumBytes) & "</pre>"

'  The BinData holds the image.  Here it is simply saved.
success = bdPng.WriteFile("qa_output/qr_in_memory.png")
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( bdPng.LastErrorText) & "</pre>"
    Response.End
End If

'  The PNG held in bdPng:

'  image

'  Sample output:

'  format: png
'  MIME type: image/png
'  image: 222 x 222 pixels
'  PNG bytes: 877

%>
</body>
</html>