Create a PDF template

This guide will show you how to create a PDF template, which is required to format a Compact or Compact Semantic Credential as a PDF document.

Prerequisites

You need the following in order to proceed with this tutorial: 

Request

Make the following request to create a Compact Credential PDF template:

http
Copy to clipboard.
1POST https://YOUR_TENANT_URL/core/v2/credentials/compact/pdf/templates
2Header: Content-Type: application/zip

The template.zip bundle must be included as a binary file in the request.

You can make a similar request to a different endpoint to create a Compact Semantic Credential PDF template:

http
Copy to clipboard.
1POST https://YOUR_TENANT_URL/core/v2/credentials/compact-semantic/pdf/templates
2Header: Content-Type: application/zip

Response

json
Copy to clipboard.
1{
2    "id": "682f203a-f5bd-4304-95e3-c8c708e90d26",
3    "name": "SamplePDF_WorkingAtHights",
4    "fileName": "{{ vc.credentialSubject.code }}_{{ vc.credentialSubject.name }}",
5    "fonts": [
6        {
7            "name": "PublicSans-Regular",
8            "fileName": "PublicSans-Regular.ttf"
9        },
10        {
11            "name": "PublicSans-Bold",
12            "fileName": "PublicSans-Bold.ttf"
13        }
14    ],
15    "fields": [
16        {
17            "key": "name",
18            "value": "{{ vc.credentialSubject.name }}",
19            "isRequired": true,
20            "alternativeText": "{{ vc.credentialSubject.name }}",
21            "fontName": "PublicSans-Regular"
22        },
23        {
24            "key": "code",
25            "value": "{{ vc.credentialSubject.code }}",
26            "isRequired": true,
27            "alternativeText": "{{ vc.credentialSubject.code }}",
28            "fontName": "PublicSans-Bold"
29        },
30        {
31            "key": "certificationName",
32            "value": "{{ vc.credentialSubject.certificationName }}",
33            "isRequired": true,
34            "alternativeText": "{{ vc.credentialSubject.certificationName }}",
35            "fontName": "PublicSans-Bold"
36        },
37        {
38            "key": "certificationLevel",
39            "value": "{{ vc.credentialSubject.certificationLevel }}",
40            "isRequired": true,
41            "alternativeText": "{{ vc.credentialSubject.certificationLevel }}",
42            "fontName": "PublicSans-Regular"
43        },
44        {
45            "key": "expiry",
46            "value": "{{ date vc.credentialSubject.expiry 'dd MMM yyyy' }}",
47            "isRequired": true,
48            "alternativeText": "{{ date vc.credentialSubject.expiry 'PPP' }}",
49            "fontName": "PublicSans-Regular"
50        }
51    ],
52    "metadata": {
53        "title": "{{ vc.credentialSubject.certificationName }} Certification – {{ vc.credentialSubject.name }}"
54    }
55}

Errors may occur in the following scenarios:

  • Unable to decompress the bundle.

  • Either template.pdf or config.json are missing from the bundle.

  • Either template.pdf or config.json are malformed.

  • Customs font are used but the font is not provided in template.zip.

  • Either template.zip or template.pdf exceed the maximum allowed file size.

  • Fields set as required in config.json are not available in template.pdf.