Sample code for 30+ languages & platforms
Visual FoxPro 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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loJson
LOCAL loFmt
LOCAL loJsonOut
LOCAL loSbSvg

lnSuccess = 0

*  This example requires the Chilkat API to have been previously unlocked.
*  See Global Unlock Sample for sample code.

loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("payload.text","https://www.chilkatsoft.com/")
loJson.UpdateString("output.format","svg")

*  An SVG is text, so it can be returned as text rather than as base64.
loJson.UpdateString("output.return","text")

loFmt = CreateObject('Chilkat.Formats')
loJsonOut = CreateObject('Chilkat.JsonObject')
lnSuccess = loFmt.QrCode("generate",loJson,loJsonOut)
IF (lnSuccess = 0) THEN
    ? loFmt.LastErrorText
    RELEASE loJson
    RELEASE loFmt
    RELEASE loJsonOut
    CANCEL
ENDIF

loSbSvg = CreateObject('Chilkat.StringBuilder')
loJsonOut.StringOfSb("outputs[0].text",loSbSvg)

? "MIME type: " + loJsonOut.StringOf("outputs[0].mimeType")
? "size: " + STR(loJsonOut.IntOf("outputs[0].width")) + " x " + STR(loJsonOut.IntOf("outputs[0].height")) + " " + loJsonOut.StringOf("outputs[0].units")
? "SVG length: " + STR(loSbSvg.Length) + " characters"

*  The SVG is a complete document that can be saved, or placed inline in an HTML page.
lnSuccess = loSbSvg.WriteFile("qa_output/qr_chilkat.svg","utf-8",0)
IF (lnSuccess = 0) THEN
    ? loSbSvg.LastErrorText
    RELEASE loJson
    RELEASE loFmt
    RELEASE loJsonOut
    RELEASE loSbSvg
    CANCEL
ENDIF

*  The SVG:

*  image

*  Sample output:

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

RELEASE loJson
RELEASE loFmt
RELEASE loJsonOut
RELEASE loSbSvg