362 Template: Training attendance notice

Training attendance notice

Type on the left - the preview on the right updates with real data from the chosen record. Click a field in the list to insert it at the cursor.

← All templates

Syntax

# Title / ## HeadingLarge title / blue sub heading
**bold words**Bold text - a whole line or just some words
^ text / > textCentred / right-aligned line
---Horizontal line
| A | B |Table row - the first row is the header
{{customer.name}}Data field (list on the right)
[[lines]] [[totals]]Invoice line table / totals (INVOICE source)
[[barcode:TEXT]] [[qr:TEXT]]Code 128 / QR code - TEXT may contain fields
[[signature:Name|Role]]Signature line
[[pagebreak]]Start a new page
Print PDF (saved version)

Training Attendance Notice

Reference CERT-2026-0006


To: Michael Brown

This notice confirms that you attended REST API Design Workshop (12 hours) and the certificate was issued on 23 October 2026.

CourseHoursGradeInstructor
REST API Design Workshop12Dr. Narin Kaewkla

Verify your certificate online:

QR code

http://localhost:8255/verify/b632fcef90b04c8f

Dr. Narin Kaewkla
Course Instructor

Fields for CERTIFICATE

{{company.name}}Northwind Print Co., Ltd.
{{company.address}}88 Rama VI Road, Ratchathewi, Bangkok 10400
{{company.taxId}}0105559999999
{{company.phone}}+66 2 123 4567
{{today}}9 November 2026
{{certificate.no}}CERT-2026-0006
{{certificate.recipient}}Michael Brown
{{certificate.course}}REST API Design Workshop
{{certificate.hours}}12
{{certificate.grade}}
{{certificate.issued}}23 October 2026
{{certificate.instructor}}Dr. Narin Kaewkla
{{certificate.verifyUrl}}http://localhost:8255/verify/b632fcef90b04c8f
{{record.label}}CERT-2026-0006
How it works
  1. DocTemplateEngine.parse(body) turns each line into a block: Heading, Text, TableBlock, Tag ... (Java 21 sealed interface + records).
  2. fill() replaces {{key}} with a regex; unknown keys show as [?key].
  3. The same blocks are rendered twice: toHtml() for this preview (a switch with pattern matching) and toPdf() with OpenPDF for printing.
  4. The data map is built from SQL Server in TemplateService.context().
for (Block b : blocks) {
    switch (b) {
        case Heading h  -> doc.add(para(fill(h.text(), ctx), Fonts.bold(18), ALIGN_LEFT, 6));
        case TableBlock t -> doc.add(tablePdf(t, ctx));
        case Tag t      -> tagPdf(doc, t, ctx, barcodes);   // [[lines]], [[qr:...]] ...
        ...
    }
}

Files: service/DocTemplateEngine.java, service/TemplateService.java, web/TemplateController.java.