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
| Property | Type | Required | Description | Default |
|---|---|---|---|---|
type | string | ✓ | Element type: qrcode | - |
qrType | string | ✓ | QR code type: url, wifi, or vcard | - |
data | object | ✓ | QR code content (structure depends on qrType) | - |
size | number | ✗ | QR code size in pixels (50-1000, always square) | 200 |
errorCorrection | string | ✗ | Error correction level: L (~7%), M (~15%), Q (~25%), H (~30%) | M |
align | string | ✗ | QR code alignment: left, center, right | left |
spacing | object | ✗ | Custom spacing override (before / after in pt) | From defaults.spacing.qrcode |
QR Code Types
URL QR Code (qrType: "url")
| Property | Type | Required | Description | Default |
|---|---|---|---|---|
qrType | string | ✓ | Must be "url" | - |
data.url | string | ✓ | URL to encode in QR code (1-2000 chars) | - |
WiFi QR Code (qrType: "wifi")
| Property | Type | Required | Description | Default |
|---|---|---|---|---|
qrType | string | ✓ | Must be "wifi" | - |
data.ssid | string | ✓ | WiFi network name (SSID, 1-32 chars) | - |
data.password | string | ✗ | WiFi password (max 63 chars) | - |
data.encryption | string | ✗ | WiFi encryption type: "WPA", "WEP", or "nopass" | "WPA" |
data.hidden | boolean | ✗ | Whether the WiFi network is hidden | false |
vCard QR Code (qrType: "vcard")
| Property | Type | Required | Description | Default |
|---|---|---|---|---|
qrType | string | ✓ | Must be "vcard" | - |
data.firstName | string | ✗ | First name (max 100 chars) | - |
data.lastName | string | ✗ | Last name (max 100 chars) | - |
data.organization | string | ✗ | Company/organization name (max 100 chars) | - |
data.phone | string | ✗ | Phone number (max 50 chars) | - |
data.email | string | ✗ | Email address (max 100 chars) | - |
data.url | string | ✗ | Website URL (max 200 chars) | - |
data.address | string | ✗ | Postal address (max 200 chars) | - |
data.note | string | ✗ | Additional notes (max 500 chars) | - |
QR Code Defaults (defaults)
For QR codes, the following defaults influence rendering:
defaults.spacing.before.qrcode/defaults.spacing.after.qrcodefor vertical spacing- The
sizeanderrorCorrectionproperties on the element itself use schema defaults (size: 200,errorCorrection: "M") when not provided.
Nested Default Properties (dot notation)
| Property | Type | Description |
|---|---|---|
defaults.spacing.before.qrcode | number | Spacing before QR code elements in pt (0-100, default: 10) |
defaults.spacing.after.qrcode | number | Spacing 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"
}
]
}
]
}