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
typestring✓Element type: qrcode-
qrTypestring✓QR code type: url, wifi, or vcard-
dataobject✓QR code content (structure depends on qrType)-
sizenumber✗QR code size in pixels (50-1000, always square)200
errorCorrectionstring✗Error correction level: L (~7%), M (~15%), Q (~25%), H (~30%)M
alignstring✗QR code alignment: left, center, rightleft
spacingobject✗Custom spacing override (before / after in pt)From defaults.spacing.qrcode

QR Code Types​

URL QR Code (qrType: "url")​

PropertyTypeRequiredDescriptionDefault
qrTypestring✓Must be "url"-
data.urlstring✓URL to encode in QR code (1-2000 chars)-

WiFi QR Code (qrType: "wifi")​

PropertyTypeRequiredDescriptionDefault
qrTypestring✓Must be "wifi"-
data.ssidstring✓WiFi network name (SSID, 1-32 chars)-
data.passwordstring✗WiFi password (max 63 chars)-
data.encryptionstring✗WiFi encryption type: "WPA", "WEP", or "nopass""WPA"
data.hiddenboolean✗Whether the WiFi network is hiddenfalse

vCard QR Code (qrType: "vcard")​

PropertyTypeRequiredDescriptionDefault
qrTypestring✓Must be "vcard"-
data.firstNamestring✗First name (max 100 chars)-
data.lastNamestring✗Last name (max 100 chars)-
data.organizationstring✗Company/organization name (max 100 chars)-
data.phonestring✗Phone number (max 50 chars)-
data.emailstring✗Email address (max 100 chars)-
data.urlstring✗Website URL (max 200 chars)-
data.addressstring✗Postal address (max 200 chars)-
data.notestring✗Additional 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"
}
]
}
]
}