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

Generate a QR Code as SVG

See more QR Code Examples

Demonstrates SVG output. An SVG is a vector image, so it stays sharp at any size, which suits print and responsive web pages. Setting output.format to svg and output.return to text returns the SVG document as a string in outputs[0].text. The SVG can also be written straight to a file with output.path, the same as a PNG.

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.UpdateString("output.format","svg")

'  An SVG is text, so it can be returned as text rather than as base64.
success = json.UpdateString("output.return","text")

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

set sbSvg = Server.CreateObject("Chilkat.StringBuilder")
success = jsonOut.StringOfSb("outputs[0].text",sbSvg)

Response.Write "<pre>" & Server.HTMLEncode( "MIME type: " & jsonOut.StringOf("outputs[0].mimeType")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "size: " & jsonOut.IntOf("outputs[0].width") & " x " & jsonOut.IntOf("outputs[0].height") & " " & jsonOut.StringOf("outputs[0].units")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "SVG length: " & sbSvg.Length & " characters") & "</pre>"

'  The SVG is a complete document that can be saved, or placed inline in an HTML page.
success = sbSvg.WriteFile("qa_output/qr_chilkat.svg","utf-8",0)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( sbSvg.LastErrorText) & "</pre>"
    Response.End
End If

'  The SVG:

'  image

'  Sample output:

'  MIME type: image/svg+xml
'  size: 148 x 148 px
'  SVG length: 12500 characters

%>
</body>
</html>