Configure PDF Credential Generation#
This guide explains how to configure the PDF credential generator using the text_elements format.
Overview#
The PDF credential generator renders text elements onto a PDF template. Three standard elements are rendered by default:
name: The learner’s name
context: The course or Learning Path name
date: The issue date
Each element can be customized, hidden, or supplemented with custom text elements.
Basic Configuration#
A minimal configuration only requires a template:
{
"template": "certificate-template"
}
This renders all three standard elements with default positioning.
Configuration Options#
Top-Level Options#
Option |
Required |
Description |
|---|---|---|
|
Yes |
The slug of the PDF template asset (from CredentialAsset). |
|
No |
Alternative template for multiline context names (when using |
|
No |
Global defaults for all text elements (see below). |
|
No |
Configuration for individual text elements (see below). |
Global Defaults#
The defaults object sets default values for all text elements:
{
"defaults": {
"font": "CustomFont",
"color": "#333333",
"size": 14,
"char_space": 0.5,
"uppercase": false,
"line_height": 1.2
}
}
Property |
Default |
Description |
|---|---|---|
|
Helvetica |
Font name (must be a CredentialAsset slug for custom fonts). |
|
#000 |
Hex color code (3 or 6 characters, with or without |
|
12 |
Font size in points. |
|
0 |
Character spacing in points. |
|
false |
Convert text to uppercase. |
|
1.1 |
Line height multiplier for multiline text. |
Text Elements#
The text_elements object configures individual elements. Standard elements (name,
context, date) have defaults and can be partially overridden:
{
"text_elements": {
"name": {"y": 300, "uppercase": true},
"context": {"size": 24},
"date": {"color": "#666666"}
}
}
Element Properties#
Property |
Default |
Description |
|---|---|---|
|
varies |
Text content with placeholder substitution. |
|
varies |
Vertical position (PDF coordinates from bottom). |
|
(inherited) |
Font size in points (inherited from |
|
(inherited) |
Font name (inherited from |
|
(inherited) |
Hex color code (inherited from |
|
(inherited) |
Character spacing (inherited from |
|
(inherited) |
Convert text to uppercase (inherited from |
|
(inherited) |
Line height multiplier for multiline text (inherited from |
Standard Element Defaults#
Element |
Text |
Y |
Size |
|---|---|---|---|
|
|
290 |
32 |
|
|
220 |
28 |
|
|
120 |
12 |
Django Settings#
Some element defaults can be overridden globally via Django settings:
Setting |
Default |
Description |
|---|---|---|
|
|
Convert name to uppercase by default. |
|
|
Convert date to uppercase by default. |
|
|
Default character spacing for date element. |
These settings are applied before per-credential configuration, allowing you to set organization-wide defaults while still permitting overrides in individual credentials.
Placeholders#
Text content supports placeholder substitution using {placeholder} syntax:
{name}- The learner’s display name{context_name}- The course or Learning Path name{issue_date}- The localized issue date{verify_uuid}- The credential’s verification UUID (for third-party verification)
To include literal braces, use {{ and }}:
{
"text": "Score: {{95%}}"
}
Hiding Elements#
Standard elements can be hidden by setting their configuration to false:
{
"text_elements": {
"date": false
}
}
Custom Elements#
Add custom text elements by using any key other than name, context, or date.
Custom elements require both text and y properties:
{
"text_elements": {
"award_line": {
"text": "Awarded on {issue_date}",
"y": 140,
"size": 14
},
"institution": {
"text": "Example University",
"y": 80,
"size": 10,
"color": "#666666"
}
}
}
Complete Example#
{
"template": "certificate-template",
"template_multiline": "certificate-multiline",
"defaults": {
"font": "OpenSans",
"color": "#333333"
},
"text_elements": {
"name": {
"y": 300,
"size": 36,
"uppercase": true
},
"context": {
"text": "Custom Course Name",
"y": 230,
"size": 24
},
"date": false,
"award_line": {
"text": "Awarded on {issue_date}",
"y": 150,
"size": 12,
"color": "#666666"
}
}
}
This configuration:
Uses
OpenSansfont and#333333color for all elementsRenders the name at y=300, size 36, in uppercase
Renders the context with custom text at y=230, size 24
Hides the default date element
Adds a custom “Awarded on [date]” line at y=150
Migration from Legacy Format#
The legacy flat format (name_y, context_name_color, etc.) has been migrated to the
new text_elements format. Existing configurations were automatically converted by
migration 0007_migrate_to_text_elements_format.
Legacy to New Format Mapping#
Legacy Option |
New Location |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|