Yes, you can generate course certificates without copying and pasting names one by one. The shortest path uses four files: a CSV of participants, an HTML template, a Python script and a SQLite database. WeasyPrint turns the HTML into a PDF, qrcode adds a verification QR code, and each file gets a unique ID.

For 500 learners, budget an evening to write and test the pipeline, then a few minutes per cohort. Five hundred PDFs at 250 KB each take 125 MB, well under the 10 GB included every month on Cloudflare R2. Delivery fits Resend's free plan if you spread the messages over five days, or its $20 per month Pro plan for 50,000 emails.

Versions and prices were checked in November 2026: WeasyPrint 70.0, Jinja 3.1.6, Typst 0.15, Resend and Cloudflare R2. The result is a certificate of completion, not a state-recognised qualification. The wording and legal value depend on your jurisdiction and on whether the course is publicly funded.

A credible certificate rests on four proofs#

A course certificate answers four questions before the reader has to contact you. Who issued it? Who received it? Which course, how many hours and on what date? And how can a third party check that the document was not edited after the fact?

The first proof is the issuer: your organisation, school or trading name, with a logo and a contact address. The second is the achievement: the exact course title, the number of hours, the completion date and, where relevant, the skills or level validated. The third is a unique identifier that is readable but hard to guess: WEB-2026-7F3A9C21B4E6D8 is better than a sequential number. The fourth is a verification path: a public URL that returns the certificate status from that identifier.

A PDF alone proves little. Any graphic editor or online tool can change a name and export the file again. What makes a certificate verifiable is the combination of an identifier, a registry you control and a public page that answers one question: does this identifier exist, and which name is it linked to? The QR code only shortens the route to that page. It does not carry the proof by itself.

For a portable proof, look at Open Badges 3.0. The standard describes a signed JSON-LD file, compatible with the W3C's Verifiable Credentials Data Model 2.0, which a learner can import into a digital wallet. That is more work than the pipeline below, but it is the right format when certificates must travel beyond your site.

The architecture: four files, two services#

The pipeline separates what changes often from what rarely changes. The participant list changes every cohort; the template changes when your brand does; the script and the registry stay stable.

File or serviceRole
participants.csvOne row per learner: name, email, course, hours
certificate.htmlThe Jinja template with the A4 landscape layout
generate.pyReads the CSV, renders the HTML, writes the PDF and fills the registry
registry.sqlite3Identifiers, SHA-256 digests and certificate status
Cloudflare R2PDF storage with no egress fees
ResendEmail delivery with the download link

SQLite is enough at this scale: the library ships with Python, the file lives on one disk and a lookup by identifier stays instant. If your learning platform already has a database, use it instead of creating a second registry. What matters is that one source of truth answers verification requests.

The registry does not store PDFs. It keeps the identifier, name, email, course, date, SHA-256 digest and a status (valid, revoked). That separation avoids duplicate documents and lets you revoke a certificate without deleting a PDF that has already been downloaded: the verification page answers "revoked" even while the file is still circulating.

Step 1: install the tool and prepare the list#

WeasyPrint 70.0 requires Python 3.10 or newer and Pango 1.44 or newer. On Debian or Ubuntu, install the system libraries before the Python package. poppler-utils comes next, to check that the PDF text can be extracted.

bash
mkdir certificates && cd certificates
python3 --version
python3 -m venv .venv
source .venv/bin/activate
sudo apt install libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0 libharfbuzz-subset0 poppler-utils
pip install "weasyprint==70.0" "jinja2==3.1.6" "qrcode[pil]" boto3
weasyprint --version

On macOS, replace the apt line with brew install pango poppler. On Windows, the simplest route is the WeasyPrint command-line executable, or WSL if you want the Linux environment. The qrcode[pil] package installs Pillow, which writes the QR code as a PNG.

participants.csv must be UTF-8 and have a header row. Export it from your LMS, Google Sheets or Excel using the "CSV UTF-8" option, not the legacy comma-separated format that uses a different encoding on older Excel versions. The script opens the file as utf-8-sig, which accepts the BOM that Excel adds.

csv
name,email,course,hours
Maya Chen,[email protected],Full-stack web development,60
Noah Williams,[email protected],Full-stack web development,60

Store only what you need. A certificate needs a name, an email, the course title and the duration. A birth date, postal address or phone number adds personal data to protect without improving the document.

Step 2: write the HTML template#

The template uses a single-column A4 landscape page and a font installed on the machine. It loads no remote resource: the QR code is embedded as a data URI, so rendering does not depend on the network.

html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Certificate — {{ learner_name }}</title>
  <style>
    @page { size: A4 landscape; margin: 0; }
    * { box-sizing: border-box; }
    body { margin: 0; font-family: "DejaVu Sans", sans-serif; color: #17211b; }
    .page { width: 297mm; height: 210mm; padding: 18mm; background: #f7f4ec; }
    .frame {
      height: 100%; border: 1.2mm solid #1f5c45; padding: 14mm;
      display: flex; flex-direction: column; justify-content: space-between;
    }
    .eyebrow { font-size: 11pt; letter-spacing: .18em; text-transform: uppercase; color: #1f5c45; }
    h1 { font-size: 34pt; margin: 4mm 0 2mm; }
    .name { font-size: 30pt; font-weight: 700; margin: 6mm 0; }
    h2 { font-size: 18pt; margin: 2mm 0; }
    .meta { font-size: 12pt; color: #4b5a51; }
    .bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 10mm; }
    .qr { width: 30mm; height: 30mm; }
    .id { font-family: monospace; font-size: 9pt; color: #4b5a51; }
  </style>
</head>
<body>
  <div class="page">
    <div class="frame">
      <p class="eyebrow">{{ issuer }}</p>
      <div>
        <h1>Certificate of completion</h1>
        <p>awarded to</p>
        <p class="name">{{ learner_name }}</p>
        <p>for completing the course</p>
        <h2>{{ course }}</h2>
        <p class="meta">{{ hours }} hours · {{ issued_on }}</p>
      </div>
      <div class="bottom">
        <div>
          <p class="id">No. {{ certificate_id }}</p>
          <p class="id">{{ verify_url }}</p>
        </div>
        <img class="qr" src="{{ qr_data_uri }}" alt="Verification QR code">
      </div>
    </div>
  </div>
</body>
</html>

Three layout choices matter. The page is landscape because a certificate reads like a poster, not a letter. The inner frame keeps a safe margin for printing. The name gets the largest type: it is the part a learner will photograph for a professional profile.

Change size: A4 landscape to size: Letter landscape for US and Canadian printers if that is your audience. A4 remains the default in most other markets. Check the font with fc-match "DejaVu Sans". If you use a brand font, copy the file to ~/.local/share/fonts, then declare it with @font-face and a local path. A missing font does not break the render: Pango substitutes another face, which can shift lines and change the certificate's appearance.

Step 3: generate the PDFs and the registry#

The script reads the CSV, creates a random identifier, builds the QR code, renders the HTML, hashes the PDF and writes both the file and the registry row. It calls write_pdf() without a target, which returns the PDF bytes in memory, as documented in the WeasyPrint API reference.

python
import base64
import csv
import hashlib
import io
import sqlite3
import uuid
from datetime import date
from pathlib import Path

import qrcode
from jinja2 import Environment, FileSystemLoader, select_autoescape
from weasyprint import HTML

ROOT = Path(__file__).parent
OUT = ROOT / "out"
OUT.mkdir(exist_ok=True)
VERIFY_BASE = "https://your-domain.tld/verify/"
ISSUER = "Acme Academy"
COURSE = "Full-stack web development"
HOURS = 60

env = Environment(
    loader=FileSystemLoader(ROOT),
    autoescape=select_autoescape(["html"]),
)
template = env.get_template("certificate.html")

db = sqlite3.connect(ROOT / "registry.sqlite3")
db.execute("""
    CREATE TABLE IF NOT EXISTS certificates (
        id TEXT PRIMARY KEY,
        name TEXT NOT NULL,
        email TEXT NOT NULL,
        course TEXT NOT NULL,
        hours INTEGER NOT NULL,
        issued_on TEXT NOT NULL,
        sha256 TEXT NOT NULL,
        status TEXT NOT NULL DEFAULT 'valid'
    )
""")

with (ROOT / "participants.csv").open(newline="", encoding="utf-8-sig") as f:
    rows = list(csv.DictReader(f))

for row in rows:
    name = row["name"].strip()
    email = row["email"].strip()
    if not name or "@" not in email:
        raise ValueError(f"Invalid row: {row}")

    cert_id = f"WEB-2026-{uuid.uuid4().hex[:16].upper()}"
    verify_url = VERIFY_BASE + cert_id
    issued_on = date.today().strftime("%Y-%m-%d")

    qr = qrcode.make(verify_url)
    buffer = io.BytesIO()
    qr.save(buffer, format="PNG")
    qr_uri = "data:image/png;base64," + base64.b64encode(buffer.getvalue()).decode()

    course = (row.get("course") or COURSE).strip()
    hours = int(row.get("hours") or HOURS)

    html = template.render(
        issuer=ISSUER,
        learner_name=name,
        course=course,
        hours=hours,
        issued_on=issued_on,
        certificate_id=cert_id,
        verify_url=verify_url,
        qr_data_uri=qr_uri,
    )

    pdf = HTML(string=html, base_url=str(ROOT)).write_pdf()
    digest = hashlib.sha256(pdf).hexdigest()
    (OUT / f"{cert_id}.pdf").write_bytes(pdf)

    db.execute(
        """INSERT INTO certificates
           (id, name, email, course, hours, issued_on, sha256)
           VALUES (?, ?, ?, ?, ?, ?, ?)""",
        (cert_id, name, email, course, hours, issued_on, digest),
    )
    print(f"{cert_id} {digest[:12]}")

db.commit()
db.close()

HTML(string=html, base_url=str(ROOT)) gives relative paths an anchor even though this template uses none. The digest is computed from the exact PDF bytes before the file is written. Re-rendering the same certificate changes the PDF (creation date, internal identifier) and therefore the digest; that is expected, because an issued certificate should not be rewritten identically.

Run the generation, then inspect one file. pdfinfo reports the page count and page size; pdftotext shows the text that a search engine or parser will read.

bash
python generate.py
ls -lh out | head
first=$(ls out/*.pdf | head -1)
pdfinfo "$first" | grep -E "Pages|Page size"
pdftotext "$first" - | head -30

The PDF should fit on one page and show the name, course, date, identifier and verification URL. If the text contains boxes instead of accented characters, the font lacks the glyphs. If pdftotext returns nothing, the document was rendered as an image, which is not what this pipeline does.

Step 4: verify a certificate#

The registry serves two purposes: answering the public page and checking that a received file matches what you issued. The script below performs the second check from the command line.

python
import hashlib
import sqlite3
import sys
from pathlib import Path

cert_id = sys.argv[1]
pdf_path = Path(sys.argv[2])

with sqlite3.connect("registry.sqlite3") as db:
    row = db.execute(
        """SELECT name, course, hours, issued_on, sha256, status
           FROM certificates WHERE id = ?""",
        (cert_id,),
    ).fetchone()

if row is None:
    raise SystemExit("Unknown certificate")

name, course, hours, issued_on, digest, status = row
if status != "valid":
    raise SystemExit(f"Certificate {status}")

if hashlib.sha256(pdf_path.read_bytes()).hexdigest() != digest:
    raise SystemExit("The PDF does not match the registry")

print(f"Valid: {name} — {course} — {hours} h — {issued_on}")
bash
python verify.py WEB-2026-7F3A9C21B4E6D8 out/WEB-2026-7F3A9C21B4E6D8.pdf

This check has a precise limit: it compares a file with your registry. It does not prove to the wider world that you are the issuer. The public page must be served from your domain and query the same database. A correct verification page shows the status, course, date and a masked name (Maya C.), never the email address. Because the identifier is random, the QR code reveals no personal data.

If you want proof that travels without your server, sign an Open Badges 3.0 assertion and publish the JSON-LD file next to the PDF. The cryptographic signature lets a third party verify the issuer without calling your database. For most independent courses, the registry and public page are enough; for funded programmes or partnerships, the standard becomes useful.

To host the verification page and the course site, our step-by-step Next.js deployment with Coolify covers the domain and HTTPS. If you prefer to keep PDFs on your own infrastructure instead of R2, our PostgreSQL backup to S3-compatible storage guide covers buckets and access keys.

Step 5: store and send#

Cloudflare R2 exposes an S3-compatible API with the region auto. Create a certificates bucket and an API token limited to that bucket, then export the three values in your terminal. Never put these keys in the Git repository.

bash
export R2_ACCOUNT_ID="your_account"
export R2_ACCESS_KEY_ID="your_key"
export R2_SECRET_ACCESS_KEY="your_secret"
python
import os
from pathlib import Path

import boto3

s3 = boto3.client(
    "s3",
    endpoint_url=f"https://{os.environ['R2_ACCOUNT_ID']}.r2.cloudflarestorage.com",
    aws_access_key_id=os.environ["R2_ACCESS_KEY_ID"],
    aws_secret_access_key=os.environ["R2_SECRET_ACCESS_KEY"],
    region_name="auto",
)

for pdf in Path("out").glob("*.pdf"):
    s3.upload_file(
        str(pdf),
        "certificates",
        f"2026/{pdf.name}",
        ExtraArgs={"ContentType": "application/pdf"},
    )

Email delivery can use the Resend API. The endpoint accepts a sender with a readable name, a recipient, a subject and an HTML body. The link points to your verification page, not to an uncontrolled public file: that way you can revoke a certificate without chasing PDFs that have already been downloaded.

bash
curl -X POST https://api.resend.com/emails \
  -H "Authorization: Bearer $RESEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "Acme Academy <[email protected]>",
    "to": ["[email protected]"],
    "subject": "Your course certificate",
    "html": "<p>Hi Maya,</p><p>Your certificate is ready: <a href=\"https://your-domain.tld/verify/WEB-2026-7F3A9C21B4E6D8\">verify and download</a>.</p>"
  }'

For a cohort, the Batch API accepts up to 100 emails per request, which avoids 500 individual HTTP calls. The free plan still limits you to 100 messages per day: 500 certificates therefore take five days, or you move to the $20 per month Pro plan. If you are comparing providers, our Resend vs Brevo vs Postmark comparison covers quotas and deliverability.

Three paths based on who runs verification#

The self-hosted pipeline gives you full control, but you maintain the script, the domain and the verification page. The other two options reduce that work, with different trade-offs.

ApproachCostSetupVerificationBest for
WeasyPrint pipeline$0 + your timeOne eveningYour page + registryDevelopers who want full control
Certifstudio20 certificates/month free; Solo €7/month annual; Pro €23/month annual4 minutesQR code and verification page includedTrainers or schools without a technical team
Typst$0, open sourceA few hoursBuild it yourselfHeavy typography or high volumes

Certifstudio, from the same publisher as this blog, lists 2,051 templates and Excel or CSV import. The free plan covers 20 certificates per month with a small Certifstudio mention; Solo raises that to 200 per month and removes the mention for €7 per month billed annually, or €9 monthly; Pro reaches 2,000 certificates per month and adds email delivery and a verification page under your name for €23 per month billed annually, or €29 monthly. It is a relevant option when the ceremony is today and nobody wants to maintain a Python script.

Typst 0.15, released on June 15, 2026, is an open-source compiler that produces PDFs from Markdown-like markup. It handles typography and layout well, but you must rewrite the template and build verification. WeasyPrint 70.0 remains the most direct choice when you already have an HTML template.

Details that save an hour#

Test long names and accents. A 45-character name can overflow the page or collide with the QR code. Add a test row with a hyphenated first name, a multi-part surname and characters such as É, ç or ñ. If the name is too long, reduce the font size or allow wrapping in .name; never clip the text.

Authenticate your domain before the first send. Resend, like other providers, requires SPF, DKIM and DMARC DNS records. Without them, messages land in spam or are rejected. Send to an address you control before writing to 500 learners.

Do not commit the registry. The SQLite file contains names and email addresses. Put it in .gitignore and back it up separately, encrypted at rest. Apply the same rule to the working CSV and the generated PDFs.

Plan for deletion. A learner can ask you to delete their data. Your registry must support deleting or anonymising the row, and the verification page should then answer "revoked" rather than keeping the name forever.

Check accessibility. WeasyPrint can produce a tagged PDF with pdf_tags=True or a PDF/UA profile with pdf_variant="pdf/ua-1", but its documentation states that validity is not guaranteed. Run the file through a PDF/UA checker and keep alternative text on the QR code. A screen reader should be able to announce the name and the course.

Keep a delivery log. Resend returns an ID for each message. Store it next to the certificate ID so you can trace a lost email without resending the PDF to the whole cohort. The API's idempotency key, valid for 24 hours, prevents duplicates when you rerun a job.

Frequently asked questions#

Frequently asked questions

Do I need a server to generate certificates?

No. The script runs on a laptop and writes PDFs to a folder. A server becomes necessary for the public verification page, email delivery and file storage if you do not want to keep your machine running.

Can I avoid Python?

Yes. Certifstudio provides CSV import and browser-based generation. Typst lets you write a template and compile it from the command line. On Node.js, libraries such as PDFKit or pdf-lib also produce PDFs, but you have to build the layout and the QR code yourself.

How do I prevent certificate forgery?

Use a random identifier, a private registry and a verification page on your domain. The QR code points to that page, which compares the identifier with the registry and returns the status. A hash inside the PDF is not enough: the verifier must trust your registry. For portable proof, sign an Open Badges 3.0 assertion.

How many certificates can I generate per minute?

It depends on the background image size, the font and the disk. Measure with time python generate.py on your machine instead of relying on a universal number. Email delivery, not PDF rendering, is often the bottleneck.

Can I send certificates with Resend's free plan?

Yes, within 3,000 emails per month and 100 per day. A cohort of 500 learners therefore takes five days, or the $20 per month Pro plan for 50,000 emails. The Batch API accepts 100 messages per request, but it does not bypass the daily limit.

Does a course certificate have official value?

It attests to what your organisation declares: completion, duration and date. It does not replace a registered professional title or a state-recognised qualification. If the course is publicly funded, check the wording required by the funder and the applicable rules before publishing the template.

Sources#

Official pages, documentation and pricing pages checked on November 7, 2026. Prices are in euros or US dollars according to the currency displayed by the publisher.