carlos / platform Public

console: the DPA PDF's HTML on the operator's letterhead

renderDPAPDF builds index.html, header.html and footer.html for the PDF
engine from the acceptance and the document and letterhead it names. The
agreement body goes in as markup only after canonicalAgreement passes on
the stored bytes; everything else is escaped. The logo is a data: URI
image (PNG or SVG), else the entity as a wordmark. The header and footer
use inline styles and Chromium's pageNumber and totalPages spans.

Deck rows PDF-C01..C14 are built. The off-origin template check allows
the PDF header's one logo tag, exactly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev cf0f0b5c916d4c61cfd84a7822df298ef5cc7d79 parent f81989a
7 files changed, +484 −0
  • internal/console/approved_dpa_pdf_copy_test.go +5 −0
  • internal/console/dpapdf.go +118 −0
  • internal/console/dpapdf_test.go +261 −0
  • internal/console/icons_test.go +36 −0
  • internal/console/templates/dpa_pdf.html +40 −0
  • internal/console/templates/dpa_pdf_footer.html +12 −0
  • internal/console/templates/dpa_pdf_header.html +12 −0

Intent

Human

<paseo-system version="1" kind="agent-message" source-agent-id="b5507fa4-1299-4449-b2cb-ecbb55b0637e" message-id="d3c25a4c-fac8-4297-809d-bf551ac620bb"> From the v0.43.8 release agent (flagship leg, on Paul&apos;s relayed GO): the 2b-2 BYO /etc preflight PASSED on 8 of the 9 flagship boxes I can reach (annie, adi, iris, barbara, both fleet box-1s, both US members: /etc and /etc/carlos root 755, no managed-box.json). I CANNOT check kepler (linux-amd64, stable channel): it is not in the flagship AWS account, not on the tailnet, and I have no SSH. The stable promote rolls kepler with everyone else; if its /etc or /etc/carlos is not root-owned or is group/other-writable, it would refuse every workload start with 409 &quot;box is joining its fleet&quot;. Plan: apt and barbara&apos;s canary now (kepler untouched). Before the stable promote I need one of: (a) someone runs on kepler: stat -c &apos;%n %U %a %F&apos; /etc /etc/carlos and it reads root, no group/other write bit; or (b) Paul accepts promoting stable without kepler&apos;s check. I will hold before the stable promote and wait for your answer (up to 30 minutes, then I stop and report). </paseo-system>

Attributed to this commit: 40.8 g CO₂e (5,296,627 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on dpa-pdf, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/console/approved_dpa_pdf_copy_test.go b/internal/console/approved_dpa_pdf_copy_test.go
index fa3765ae8..ba4730976 100644
--- a/internal/console/approved_dpa_pdf_copy_test.go
+++ b/internal/console/approved_dpa_pdf_copy_test.go
@@ -22,6 +22,11 @@ const (
// named test must exist.
var dpaPDFCopyBuilt = map[string]bool{
// Tasks 1 and 3 add their ids here as they write the text.
+ // Task 1: the PDF's HTML (dpapdf.go and templates/dpa_pdf*.html).
+ "PDF-C01": true, "PDF-C02": true, "PDF-C03": true, "PDF-C04": true,
+ "PDF-C05": true, "PDF-C06": true, "PDF-C07": true, "PDF-C08": true,
+ "PDF-C09": true, "PDF-C10": true, "PDF-C11": true, "PDF-C12": true,
+ "PDF-C13": true, "PDF-C14": true,
}
func parseDPAPDFCopyDeck(t *testing.T) []navCopyRow {
diff --git a/internal/console/dpapdf.go b/internal/console/dpapdf.go
new file mode 100644
index 000000000..e829c8c14
--- /dev/null
+++ b/internal/console/dpapdf.go
@@ -0,0 +1,118 @@
+package console
+
+import (
+ "bytes"
+ "encoding/base64"
+ "fmt"
+ "html/template"
+ "strconv"
+ "strings"
+)
+
+// The executed data processing agreement as HTML on the operator's
+// letterhead (DPA and retention spec §3.8), for the PDF engine's
+// forms/chromium/convert/html: index.html is the document, header.html and
+// footer.html are the page header and footer Chromium repeats on every page.
+// All three are self-contained: no script, no stylesheet or font to fetch, and
+// the logo, if any, is a data: URI image.
+
+// dpaPDFInput is what the PDF shows: the acceptance and the document and
+// letterhead it names, and the console's name.
+type dpaPDFInput struct {
+ Acceptance DPAAcceptance
+ Doc LegalDocument
+ Letterhead Letterhead
+ ConsoleName string
+}
+
+// dpaPDFTemplates are standalone documents, not the console's chrome. The
+// console's own set parses them too (templates/*.html), harmlessly.
+var dpaPDFTemplates = template.Must(template.New("dpa_pdf.html").ParseFS(tmplFS,
+ "templates/dpa_pdf.html", "templates/dpa_pdf_header.html", "templates/dpa_pdf_footer.html"))
+
+// dpaPDFLogoTypes are the logo types embedded; any other gives the wordmark.
+var dpaPDFLogoTypes = map[string]bool{"image/png": true, "image/svg+xml": true}
+
+// dpaPDFDateLayout and dpaPDFTimeLayout are pdf.exec.customer_line's {date}
+// and {time}, in UTC.
+const (
+ dpaPDFDateLayout = "2 January 2006"
+ dpaPDFTimeLayout = "15:04"
+)
+
+// dpaPDFView is what the three templates read.
+type dpaPDFView struct {
+ Version string
+ Processor string // dpa.record.processor (+ processor_vat)
+
+ LegalName string
+ AddressLines []string
+ Country string
+ Body template.HTML // canonicalAgreement passed on these bytes
+
+ Console, AcceptedBy, Date, Time string
+ SignerName, SignerRole string
+ Signatory string
+ URL, SHA256 string
+ RecordID string
+
+ // The page header.
+ LogoURL template.URL // a data: URI, or empty for the wordmark
+ Entity string
+ PrivacyAddress string
+
+ // The page footer.
+ Office, CompanyNumber, VATNumber, Footer string
+}
+
+// renderDPAPDF builds the PDF's index.html, header.html and footer.html. The
+// agreement body goes in as markup only if canonicalAgreement passes on the
+// exact stored bytes; otherwise it is an error and no HTML.
+func renderDPAPDF(in dpaPDFInput) (index, header, footer []byte, err error) {
+ if err := canonicalAgreement([]byte(in.Doc.Body)); err != nil {
+ return nil, nil, nil, fmt.Errorf("dpa pdf: document %d is not canonical: %w", in.Doc.ID, err)
+ }
+ a, lh := in.Acceptance, in.Letterhead
+ country := a.Country
+ if n, ok := countryNames[country]; ok {
+ country = n
+ }
+ v := dpaPDFView{
+ Version: in.Doc.Version,
+ Processor: dpaRecordProcessorText(&lh),
+ LegalName: a.LegalName,
+ AddressLines: strings.Split(strings.ReplaceAll(a.Address, "\r\n", "\n"), "\n"),
+ Country: country,
+ Body: template.HTML(in.Doc.Body), // canonicalAgreement just passed
+ Console: in.ConsoleName,
+ AcceptedBy: a.AcceptedBy,
+ Date: a.AcceptedAt.UTC().Format(dpaPDFDateLayout),
+ Time: a.AcceptedAt.UTC().Format(dpaPDFTimeLayout),
+ SignerName: a.SignerName,
+ SignerRole: a.SignerRole,
+ Signatory: strings.TrimSuffix(lh.Signatory, "."), // the line adds its own full stop
+ URL: in.Doc.URL,
+ SHA256: in.Doc.SHA256,
+ RecordID: strconv.FormatInt(a.ID, 10),
+ Entity: lh.Entity,
+ PrivacyAddress: lh.PrivacyAddress,
+ Office: lh.RegisteredOffice,
+ CompanyNumber: lh.CompanyNumber,
+ VATNumber: lh.VATNumber,
+ Footer: lh.Footer,
+ }
+ if len(lh.Logo) > 0 && dpaPDFLogoTypes[lh.LogoType] {
+ // The type is from the allow-list and base64 has no character that
+ // needs escaping, so the URI is exactly these bytes.
+ v.LogoURL = template.URL("data:" + lh.LogoType + ";base64," + base64.StdEncoding.EncodeToString(lh.Logo))
+ }
+ out := make([][]byte, 3)
+ for i, name := range []string{"dpa_pdf.html", "dpa_pdf_header.html", "dpa_pdf_footer.html"} {
+ var b bytes.Buffer
+ if err := dpaPDFTemplates.ExecuteTemplate(&b, name, v); err != nil {
+ return nil, nil, nil, fmt.Errorf("dpa pdf: %s: %w", name, err)
+ }
+ out[i] = b.Bytes()
+ }
+ return out[0], out[1], out[2], nil
+}
diff --git a/internal/console/dpapdf_test.go b/internal/console/dpapdf_test.go
new file mode 100644
index 000000000..d145efeb2
--- /dev/null
+++ b/internal/console/dpapdf_test.go
@@ -0,0 +1,261 @@
+package console
+
+import (
+ "encoding/base64"
+ "strings"
+ "testing"
+ "time"
+
+ "golang.org/x/net/html"
+)
+
+// dpaPDFTestBody is a canonical agreement fragment, as publishing stores it.
+const dpaPDFTestBody = `<section>
+<h2>Who this is between</h2>
+<p>It is between Team Tito Limited and the customer named when the agreement was accepted. It is part of our <a href="https://carloku.com/terms/">terms</a>.</p>
+</section>`
+
+func dpaPDFTestInput() dpaPDFInput {
+ return dpaPDFInput{
+ Acceptance: DPAAcceptance{
+ ID: 42, AccountID: 7, DocumentID: 3, LetterheadID: 5,
+ LegalName: "Shop Limited", Address: "1 Example Street\nDublin", Country: "IE",
+ SignerName: "Ada Lovelace", SignerRole: "Director",
+ AcceptedBy: "you@example.com", AcceptedIP: "192.0.2.1",
+ AcceptedAt: time.Date(2026, 11, 26, 10, 14, 59, 0, time.UTC),
+ },
+ Doc: LegalDocument{
+ ID: 3, Kind: "dpa", Version: "1", URL: "https://carloku.com/dpa/1/",
+ BodyURL: "https://carloku.com/dpa/1/agreement.html", Body: dpaPDFTestBody,
+ SHA256: "3f2a9c1e5b7d4a8f0e6c2b9d1a7f3e5c8b4d0a6e2f9c7b1d5a3e8f0c6b2d9a4e",
+ },
+ Letterhead: Letterhead{
+ ID: 5, Entity: "Team Tito Limited",
+ RegisteredOffice: "27 Frederick Street South, Dublin D02 T254, Ireland",
+ CompanyNumber: "566334", VATNumber: "IE3384527RH",
+ Signatory: "For and on behalf of Team Tito Limited",
+ PrivacyAddress: "privacy@carloku.com",
+ Footer: "Carloku is run by Team Tito Limited.",
+ },
+ ConsoleName: "Carloku",
+ }
+}
+
+func renderDPAPDFAll(t *testing.T, in dpaPDFInput) (index, header, footer string) {
+ t.Helper()
+ i, h, f, err := renderDPAPDF(in)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return string(i), string(h), string(f)
+}
+
+func TestDPAPDFHTMLHasEveryPart(t *testing.T) {
+ in := dpaPDFTestInput()
+ index, header, footer := renderDPAPDFAll(t, in)
+ all := index + header + footer
+ for _, want := range []string{
+ "Team Tito Limited",
+ "27 Frederick Street South, Dublin D02 T254, Ireland",
+ "566334",
+ "IE3384527RH",
+ "Carloku is run by Team Tito Limited.",
+ "Version 1",
+ "Shop Limited",
+ "1 Example Street",
+ "Dublin",
+ "Ireland",
+ "Ada Lovelace",
+ "Director",
+ "you@example.com",
+ "26 November 2026",
+ "10:14",
+ "https://carloku.com/dpa/1/",
+ in.Doc.SHA256,
+ "Record 42",
+ "It is between Team Tito Limited and the customer named when the agreement was accepted.",
+ "For and on behalf of Team Tito Limited",
+ } {
+ if !strings.Contains(all, want) {
+ t.Errorf("the PDF's HTML is missing %q", want)
+ }
+ }
+ // The letterhead sits in the page header and the office in the page
+ // footer, which Chromium repeats on every page.
+ if !strings.Contains(header, "Team Tito Limited") {
+ t.Errorf("header has no entity:\n%s", header)
+ }
+ for _, want := range []string{"27 Frederick Street South", "Company number 566334", "VAT number IE3384527RH", "Carloku is run by Team Tito Limited.", "Version 1"} {
+ if !strings.Contains(footer, want) {
+ t.Errorf("footer is missing %q:\n%s", want, footer)
+ }
+ }
+ // The agreement is placed as markup, links and all.
+ if !strings.Contains(index, `<a href="https://carloku.com/terms/">terms</a>`) {
+ t.Errorf("the agreement body is not placed as markup:\n%s", index)
+ }
+
+ // No VAT number: none in the footer or the parties.
+ in.Letterhead.VATNumber = ""
+ index, _, footer = renderDPAPDFAll(t, in)
+ if strings.Contains(index+footer, "VAT") {
+ t.Error("a letterhead with no VAT number still prints one")
+ }
+}
+
+func TestDPAPDFCopy(t *testing.T) {
+ index, _, footer := renderDPAPDFAll(t, dpaPDFTestInput())
+ for _, want := range []string{
+ // PDF-C02
+ "Version 1",
+ // PDF-C07
+ "Accepted electronically in the Carloku console by you@example.com, on 26 November 2026 at 10:14 UTC.",
+ // PDF-C08
+ "For the customer: Ada Lovelace, Director, Shop Limited.",
+ // PDF-C09
+ "For the processor: For and on behalf of Team Tito Limited. The agreement was formed when the customer accepted it.",
+ // PDF-C10
+ "Agreement text: https://carloku.com/dpa/1/",
+ // PDF-C11
+ "Fingerprint of the text (SHA-256): <code>3f2a9c1e5b7d4a8f0e6c2b9d1a7f3e5c8b4d0a6e2f9c7b1d5a3e8f0c6b2d9a4e</code>",
+ // PDF-C13
+ "Record 42 in the Carloku console.",
+ // DPA-C36 and DPA-C37, the processor in the parties block.
+ "Team Tito Limited, 27 Frederick Street South, Dublin D02 T254, Ireland. Company number 566334. VAT number IE3384527RH.",
+ } {
+ if !strings.Contains(index, want) {
+ t.Errorf("index.html is missing %q", want)
+ }
+ }
+ // PDF-C14, with Chromium's page counters as the values.
+ if want := `Page <span class="pageNumber"></span> of <span class="totalPages"></span>`; !strings.Contains(footer, want) {
+ t.Errorf("footer.html is missing %q:\n%s", want, footer)
+ }
+}
+
+func TestDPAPDFHTMLEscapes(t *testing.T) {
+ in := dpaPDFTestInput()
+ in.Acceptance.LegalName = "Shop <b>Limited</b>"
+ in.Acceptance.Address = "1 Example Street\r\nDublin <i>2</i>"
+ index, _, _ := renderDPAPDFAll(t, in)
+ if strings.Contains(index, "<b>Limited</b>") || !strings.Contains(index, "Shop &lt;b&gt;Limited&lt;/b&gt;") {
+ t.Errorf("the legal name is not escaped:\n%s", index)
+ }
+ if !strings.Contains(index, "1 Example Street<br>Dublin &lt;i&gt;2&lt;/i&gt;") {
+ t.Errorf("a two-line address is not two escaped lines:\n%s", index)
+ }
+}
+
+func TestDPAPDFLogoIsDataURIImage(t *testing.T) {
+ for _, tc := range []struct {
+ name, typ string
+ logo []byte
+ }{
+ // Bytes whose base64 has "+" and "/", which the attribute must keep.
+ {"png", "image/png", []byte("\x89PNG\r\n\x1a\n\xfb\xef\xff\xfe")},
+ {"svg", "image/svg+xml", []byte(`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><rect width="10" height="10"/></svg>`)},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ in := dpaPDFTestInput()
+ in.Letterhead.Logo, in.Letterhead.LogoType = tc.logo, tc.typ
+ index, header, footer := renderDPAPDFAll(t, in)
+ want := "data:" + tc.typ + ";base64," + base64.StdEncoding.EncodeToString(tc.logo)
+ if got := dpaPDFSrcs(t, header); len(got) != 1 || got[0] != "img "+want {
+ t.Errorf("header's sources are %q, want only the %s data URI image", got, tc.typ)
+ }
+ if got := dpaPDFSrcs(t, index+footer); len(got) != 0 {
+ t.Errorf("index and footer have sources %q, want none", got)
+ }
+ all := index + header + footer
+ for _, bad := range []string{"<svg", "xlink"} {
+ if strings.Contains(all, bad) {
+ t.Errorf("the output carries %q", bad)
+ }
+ }
+ if strings.Contains(header, `class="wordmark"`) {
+ t.Error("a logo is shown and the wordmark too")
+ }
+ })
+ }
+ t.Run("no logo", func(t *testing.T) {
+ _, header, _ := renderDPAPDFAll(t, dpaPDFTestInput())
+ if strings.Contains(header, "<img") {
+ t.Errorf("no logo, yet an image:\n%s", header)
+ }
+ if !strings.Contains(header, `class="wordmark"`) || !strings.Contains(header, ">Team Tito Limited</") {
+ t.Errorf("no logo should give the entity as a wordmark:\n%s", header)
+ }
+ })
+ t.Run("other type", func(t *testing.T) {
+ in := dpaPDFTestInput()
+ in.Letterhead.Logo, in.Letterhead.LogoType = []byte("GIF89a"), "image/gif"
+ _, header, _ := renderDPAPDFAll(t, in)
+ if strings.Contains(header, "<img") || !strings.Contains(header, `class="wordmark"`) {
+ t.Errorf("a logo of another type should give the wordmark:\n%s", header)
+ }
+ })
+}
+
+func TestDPAPDFNoExternalResources(t *testing.T) {
+ in := dpaPDFTestInput()
+ in.Letterhead.Logo, in.Letterhead.LogoType = []byte("\x89PNG\r\n\x1a\n"), "image/png"
+ index, header, footer := renderDPAPDFAll(t, in)
+ for name, out := range map[string]string{"index.html": index, "header.html": header, "footer.html": footer} {
+ lower := strings.ToLower(out)
+ for _, bad := range []string{`src="http`, `src="//`, "<link", "<script", "@import", "url(", "@font-face"} {
+ if strings.Contains(lower, bad) {
+ t.Errorf("%s carries %q", name, bad)
+ }
+ }
+ if !strings.HasPrefix(out, "<!doctype html>") {
+ t.Errorf("%s is not a whole HTML document", name)
+ }
+ }
+ // Chromium's header and footer templates need inline styles and an
+ // explicit font size.
+ for name, out := range map[string]string{"header.html": header, "footer.html": footer} {
+ if strings.Contains(out, "<style") || !strings.Contains(out, "font-size:") {
+ t.Errorf("%s should carry inline styles with a font size:\n%s", name, out)
+ }
+ }
+}
+
+func TestDPAPDFRefusesNonCanonicalBody(t *testing.T) {
+ for _, body := range []string{
+ `<p>Hello</p><script>alert(1)</script>`,
+ `<p>Hello <img src="https://example.com/x.png"></p>`,
+ `<p>Unclosed`,
+ `<p onclick="x()">Hi</p>`,
+ } {
+ in := dpaPDFTestInput()
+ in.Doc.Body = body
+ index, header, footer, err := renderDPAPDF(in)
+ if err == nil {
+ t.Errorf("body %q: no error", body)
+ }
+ if index != nil || header != nil || footer != nil {
+ t.Errorf("body %q: HTML returned with the error", body)
+ }
+ }
+}
+
+// dpaPDFSrcs is every src attribute in doc as "element value", the value as
+// a browser reads it (entities decoded).
+func dpaPDFSrcs(t *testing.T, doc string) []string {
+ t.Helper()
+ var out []string
+ z := html.NewTokenizer(strings.NewReader(doc))
+ for {
+ switch z.Next() {
+ case html.ErrorToken:
+ return out
+ case html.StartTagToken, html.SelfClosingTagToken:
+ tok := z.Token()
+ for _, a := range tok.Attr {
+ if a.Key == "src" {
+ out = append(out, tok.Data+" "+a.Val)
+ }
+ }
+ }
+ }
+}
diff --git a/internal/console/icons_test.go b/internal/console/icons_test.go
index 12fa98230..26eb6244f 100644
--- a/internal/console/icons_test.go
+++ b/internal/console/icons_test.go
@@ -64,6 +64,8 @@ func TestSwitcherChromeIsInlineSVGNotTextGlyphs(t *testing.T) {
// sameOriginAssetTags is the exact shape it may use. The demo claim page
// may load only its embedded demo_claim.js through the same asset helper.
// Its shared console styles are inline and covered by an exact CSP hash.
+// The DPA PDF's page header (dpa_pdf_header.html) may carry its one logo
+// image, whose src is always a data: URI built in dpapdf.go.
func TestConsoleTemplatesFetchNothingOffOrigin(t *testing.T) {
err := fs.WalkDir(tmplFS, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil || d.IsDir() {
@@ -111,6 +113,32 @@ func TestConsoleTemplatesOffOriginCheckRefusesLiteralURLsInTheShell(t *testing.T
}
}
+// The DPA PDF header's allowance is its one logo tag, exactly: another image,
+// a second logo tag, or the logo tag in another template still fails.
+func TestConsoleTemplatesOffOriginCheckAllowsOnlyThePDFLogo(t *testing.T) {
+ header, err := tmplFS.ReadFile("templates/dpa_pdf_header.html")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !strings.Contains(string(header), dpaPDFHeaderLogoTag) {
+ t.Fatal("dpa_pdf_header.html no longer has the logo tag the allowance names")
+ }
+ if got := offOriginFetches("templates/dpa_pdf_header.html", string(header)); len(got) != 0 {
+ t.Fatalf("the shipped dpa_pdf_header.html should pass, found %q", got)
+ }
+ for _, tc := range []struct{ name, path, src string }{
+ {"https image", "templates/dpa_pdf_header.html", string(header) + `<img src="https://example.com/x.png">`},
+ {"second logo tag", "templates/dpa_pdf_header.html", string(header) + dpaPDFHeaderLogoTag},
+ {"logo tag in another template", "templates/dpa_pdf.html", dpaPDFHeaderLogoTag},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ if got := offOriginFetches(tc.path, tc.src); len(got) == 0 {
+ t.Errorf("%s passed the off-origin check", tc.name)
+ }
+ })
+ }
+}
+
// offOriginFetches returns every banned spelling found in a template.
func offOriginFetches(path, src string) []string {
banned := []string{
@@ -133,6 +161,9 @@ func offOriginFetches(path, src string) []string {
if path == "templates/demo_claim.html" {
src = strings.ReplaceAll(src, `<script src="{{asset "demo_claim.js"}}"></script>`, "")
}
+ if path == "templates/dpa_pdf_header.html" {
+ src = strings.Replace(src, dpaPDFHeaderLogoTag, "", 1)
+ }
var found []string
for _, bad := range banned {
if strings.Contains(src, bad) {
@@ -156,6 +187,11 @@ var sameOriginAssetTags = func() *regexp.Regexp {
`|<script` + attr + `\s+src=` + asset + attr + `\s*>`)
}()
+// dpaPDFHeaderLogoTag is the DPA PDF header's logo image, exactly. Its
+// LogoURL is a template.URL that renderDPAPDF only ever sets to a data: URI
+// (TestDPAPDFLogoIsDataURIImage).
+const dpaPDFHeaderLogoTag = `<img src="{{.LogoURL}}" alt="{{.Entity}}" style="display: block; max-height: 28pt; max-width: 3in;">`
+
var iconCall = regexp.MustCompile(`{{\s*icon\s+"([^"]*)"\s*}}`)
// icon returns "" for an unknown slug so a typo cannot 500 a page mid-render.
diff --git a/internal/console/templates/dpa_pdf.html b/internal/console/templates/dpa_pdf.html
new file mode 100644
index 000000000..f76db3a8b
--- /dev/null
+++ b/internal/console/templates/dpa_pdf.html
@@ -0,0 +1,40 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<title>Data processing agreement</title>
+<style>
+body { font: 10.5pt/1.5 Georgia, 'Times New Roman', serif; color: #111; margin: 0; }
+h1 { font: 700 22pt/1.2 Helvetica, Arial, sans-serif; margin: 0 0 4pt; }
+.ver { color: #555; margin: 0 0 18pt; }
+h2 { font: 700 12pt Helvetica, Arial, sans-serif; margin: 18pt 0 6pt; }
+h3 { font: 700 10.5pt Helvetica, Arial, sans-serif; margin: 12pt 0 4pt; }
+a { color: inherit; }
+.parties { display: grid; grid-template-columns: 7em 1fr; gap: 4pt 12pt; border: 1px solid #ccc; padding: 10pt; margin-bottom: 18pt; break-inside: avoid; }
+.parties b { font-family: Helvetica, Arial, sans-serif; font-size: 9pt; text-transform: uppercase; letter-spacing: .06em; color: #555; }
+.exec { break-before: page; }
+code { font: 9pt ui-monospace, Menlo, monospace; word-break: break-all; }
+.hint { font-size: 9pt; color: #555; }
+</style>
+</head>
+<body>
+<h1>Data processing agreement</h1>
+<p class="ver">Version {{.Version}}</p>
+<h2>The parties</h2>
+<div class="parties"><b>Processor</b><span>{{.Processor}}</span>
+<b>Customer</b><span>{{.LegalName}}{{range .AddressLines}}<br>{{.}}{{end}}<br>{{.Country}}</span></div>
+<div class="agreement">
+{{.Body}}
+</div>
+<section class="exec">
+<h2>Acceptance</h2>
+<p>Accepted electronically in the {{.Console}} console by {{.AcceptedBy}}, on {{.Date}} at {{.Time}} UTC.</p>
+<p>For the customer: {{.SignerName}}, {{.SignerRole}}, {{.LegalName}}.</p>
+<p>For the processor: {{.Signatory}}. The agreement was formed when the customer accepted it.</p>
+<p>Agreement text: {{.URL}}</p>
+<p>Fingerprint of the text (SHA-256): <code>{{.SHA256}}</code></p>
+<p class="hint">The fingerprint changes if a single character of the agreement changes, so it proves which text was accepted.</p>
+<p>Record {{.RecordID}} in the {{.Console}} console.</p>
+</section>
+</body>
+</html>
diff --git a/internal/console/templates/dpa_pdf_footer.html b/internal/console/templates/dpa_pdf_footer.html
new file mode 100644
index 000000000..19d59845b
--- /dev/null
+++ b/internal/console/templates/dpa_pdf_footer.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html lang="en">
+<head><meta charset="utf-8"></head>
+<body style="margin: 0;">
+<div style="box-sizing: border-box; width: 100%; padding: 0.3in 0.8in 0; font-family: Helvetica, Arial, sans-serif; font-size: 8pt; color: #555; -webkit-print-color-adjust: exact;">
+<div style="display: flex; justify-content: space-between; gap: 12pt; border-top: 1px solid #999; padding-top: 6pt;">
+<span>{{.Office}} · Company number {{.CompanyNumber}}{{if .VATNumber}} · VAT number {{.VATNumber}}{{end}}{{if .Footer}} · {{.Footer}}{{end}}</span>
+<span style="white-space: nowrap;">Version {{.Version}} · Page <span class="pageNumber"></span> of <span class="totalPages"></span></span>
+</div>
+</div>
+</body>
+</html>
diff --git a/internal/console/templates/dpa_pdf_header.html b/internal/console/templates/dpa_pdf_header.html
new file mode 100644
index 000000000..b2df07549
--- /dev/null
+++ b/internal/console/templates/dpa_pdf_header.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html lang="en">
+<head><meta charset="utf-8"></head>
+<body style="margin: 0;">
+<div style="box-sizing: border-box; width: 100%; padding: 0.3in 0.8in 0; font-family: Helvetica, Arial, sans-serif; font-size: 8pt; color: #555; -webkit-print-color-adjust: exact;">
+<div style="display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1px solid #999; padding-bottom: 6pt;">
+{{- if .LogoURL}}<img src="{{.LogoURL}}" alt="{{.Entity}}" style="display: block; max-height: 28pt; max-width: 3in;">
+{{- else}}<span class="wordmark" style="font-weight: 700; font-size: 16pt; letter-spacing: .01em; color: #111;">{{.Entity}}</span>
+{{- end}}<span style="font-size: 8pt;">{{.PrivacyAddress}}</span></div>
+</div>
+</body>
+</html>