Skip to main content

QR Code Elements

This page shows how to use the qrcode element in json2doc.

note

QR codes are ideal for quickly sharing links, connection details, or contact information:

  • URL – link to websites, dashboards, documentation, etc.
  • WiFi – allow users to join a WiFi network without typing credentials.
  • vCard – share contact details that can be saved directly to an address book.

QR Code Properties & Defaults

QR Code Element Properties

PropertyTypeRequiredDescriptionDefault
typestringElement type: qrcode-
qrTypestringQR code type: url, wifi, or vcard-
dataobjectQR code content (structure depends on qrType)-
sizenumberQR code size in pixels (50-1000, always square)200
errorCorrectionstringError correction level: L (~7%), M (~15%), Q (~25%), H (~30%)M
alignstringQR code alignment: left, center, rightleft
spacingobjectCustom spacing override (before / after in pt)From defaults.spacing.qrcode

QR Code Types

URL QR Code (qrType: "url")

PropertyTypeRequiredDescriptionDefault
qrTypestringMust be "url"-
data.urlstringURL to encode in QR code (1-2000 chars)-

WiFi QR Code (qrType: "wifi")

PropertyTypeRequiredDescriptionDefault
qrTypestringMust be "wifi"-
data.ssidstringWiFi network name (SSID, 1-32 chars)-
data.passwordstringWiFi password (max 63 chars)-
data.encryptionstringWiFi encryption type: "WPA", "WEP", or "nopass""WPA"
data.hiddenbooleanWhether the WiFi network is hiddenfalse

vCard QR Code (qrType: "vcard")

PropertyTypeRequiredDescriptionDefault
qrTypestringMust be "vcard"-
data.firstNamestringFirst name (max 100 chars)-
data.lastNamestringLast name (max 100 chars)-
data.organizationstringCompany/organization name (max 100 chars)-
data.phonestringPhone number (max 50 chars)-
data.emailstringEmail address (max 100 chars)-
data.urlstringWebsite URL (max 200 chars)-
data.addressstringPostal address (max 200 chars)-
data.notestringAdditional notes (max 500 chars)-

QR Code Defaults (defaults)

For QR codes, the following defaults influence rendering:

  • defaults.spacing.before.qrcode / defaults.spacing.after.qrcode for vertical spacing
  • The size and errorCorrection properties on the element itself use schema defaults (size: 200, errorCorrection: "M") when not provided.

Nested Default Properties (dot notation)

PropertyTypeDescription
defaults.spacing.before.qrcodenumberSpacing before QR code elements in pt (0-100, default: 10)
defaults.spacing.after.qrcodenumberSpacing after QR code elements in pt (0-100, default: 15)

Defaults Example

{
"document": {
"type": "pdf",
"filename": "qrcode-defaults-example"
},
"defaults": {
"spacing": {
"before": {
"qrcode": 12
},
"after": {
"qrcode": 18
}
}
},
"sections": []
}

URL QR Code Example

URL QR Code JSON
{
"document": {
"type": "pdf",
"filename": "qrcode-url-example"
},
"sections": [
{
"type": "flow",
"content": [
{
"type": "h2",
"text": "URL QR Code"
},
{
"type": "text",
"text": "Scan this QR code to visit the json2doc website:"
},
{
"type": "qrcode",
"qrType": "url",
"data": {
"url": "https://www.json2doc.com"
},
"size": 180,
"align": "center",
"errorCorrection": "M",
"spacing": {
"before": 10,
"after": 20
}
}
]
}
]
}

WiFi QR Code Example

WiFi QR Code JSON
{
"document": {
"type": "pdf",
"filename": "qrcode-wifi-example"
},
"sections": [
{
"type": "flow",
"content": [
{
"type": "h2",
"text": "WiFi QR Code"
},
{
"type": "text",
"text": "Scan to connect to the Office WiFi network:"
},
{
"type": "qrcode",
"qrType": "wifi",
"data": {
"ssid": "Office-Network",
"password": "SecurePassword123",
"encryption": "WPA",
"hidden": false
},
"size": 200,
"align": "center",
"errorCorrection": "H"
}
]
}
]
}

vCard QR Code Example

vCard QR Code JSON
{
"document": {
"type": "pdf",
"filename": "qrcode-vcard-example"
},
"sections": [
{
"type": "flow",
"content": [
{
"type": "h2",
"text": "vCard QR Code"
},
{
"type": "text",
"text": "Scan to save this contact:"
},
{
"type": "qrcode",
"qrType": "vcard",
"data": {
"firstName": "John",
"lastName": "Doe",
"organization": "json2doc Example",
"phone": "+49 30 1234 5678",
"email": "john.doe@json2doc.com",
"url": "https://www.json2doc.com",
"address": "Alexanderplatz 1, 10178 Berlin, Germany",
"note": "Senior Consultant"
},
"size": 220,
"align": "center",
"errorCorrection": "H"
}
]
}
]
}