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

Embed a QR Code in HTML as a Data URI

See more QR Code Examples

Demonstrates putting a QR code directly into an HTML page or HTML email with no separate image file. The base64 PNG returned by QrCode becomes the src of an img tag as a data URI, which is the MIME type from outputs[0].mimeType followed by the base64 from outputs[0].base64.

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",5)

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

'  A data URI has the form  data:<MIME type>;base64,<base64 data>
set sbHtml = Server.CreateObject("Chilkat.StringBuilder")
success = sbHtml.Append("<html><body><p>Scan to visit chilkatsoft.com</p><img alt=""QR code"" width=""")
success = sbHtml.AppendInt(jsonOut.IntOf("outputs[0].width"))
success = sbHtml.Append(""" height=""")
success = sbHtml.AppendInt(jsonOut.IntOf("outputs[0].height"))
success = sbHtml.Append(""" src=""data:")
success = sbHtml.Append(jsonOut.StringOf("outputs[0].mimeType"))
success = sbHtml.Append(";base64,")
success = sbHtml.Append(jsonOut.StringOf("outputs[0].base64"))
success = sbHtml.Append("""></body></html>")

success = sbHtml.WriteFile("qa_output/qr_page.html","utf-8",0)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( sbHtml.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "image: " & jsonOut.IntOf("outputs[0].width") & " x " & jsonOut.IntOf("outputs[0].height") & " pixels") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "HTML length: " & sbHtml.Length) & "</pre>"

'  The page, as a browser shows it:

'  image

'  Sample output:

'  image: 185 x 185 pixels
'  HTML length: 1211

%>
</body>
</html>