# dompdf Investigation Findings (2026-04-20)

## Scope

Investigation run against:

- `samples/renewal_draft.html`
- `samples/invoicing.html`

Using spike script:

- `working/codex-spikes/dompdf_spike.php`

## Execution Summary

- dompdf installed via Composer: `dompdf/dompdf v3.1.5`.
- Spike rendered both templates to PDF successfully (exit code 0).
- Output PDF metadata confirms:
  - producer `dompdf 3.1.5 + CPDF`
  - `Pages: 1`
  - `A4` page size for both files.

Generated artefacts:

- `working/dompdf/rendered_html/renewal_draft.rendered.html`
- `working/dompdf/rendered_html/invoicing.rendered.html`
- `working/dompdf/pdfs/renewal_draft.pdf`
- `working/dompdf/pdfs/invoicing.pdf`

## Objective Checks

1. Render success
   - Result: PASS
   - Evidence: spike script completed and wrote both PDFs.

2. Unicode/currency symbols in invoicing output
   - Result: PARTIAL
   - Evidence:
     - `£` extracted correctly from PDF text.
     - `✉` extracted correctly from PDF text.
     - phone symbol `📞` extracted as replacement glyphs (`��`) in text extraction.
   - Interpretation: likely font/glyph coverage issue for this symbol.

3. Renewal draft watermark and complex layout
   - Result: PARTIAL
   - Evidence:
     - watermark text appears in extracted PDF text stream as split/reordered letters, indicating transformed/fixed-position content was processed.
   - Interpretation: confirms render path handled transformed watermark content, but fidelity must be visually verified.

4. Tables/spacing/mm layout constraints
   - Result: NOT YET VERIFIED
   - Evidence: no browser baseline comparison completed in this run.

## Recorded File Fingerprints

- `working/dompdf/pdfs/invoicing.pdf`
  - sha256: `881ce70e95621423c7b0629e777190ee6c6e64079103e7c81ae18f46bbf5111a`
- `working/dompdf/pdfs/renewal_draft.pdf`
  - sha256: `a92e64b4ebe7553068163f07d108d1cfadfd8955f1ec4940811dfafd540a73e7`
- `working/dompdf/rendered_html/invoicing.rendered.html`
  - sha256: `9f5182485e21e979cf9b0eb1ed0500381a62d3d9269e5a2d19f080f4a8a34a1c`
- `working/dompdf/rendered_html/renewal_draft.rendered.html`
  - sha256: `b81b8fea7f07bcdf32667adc27f88cc060c1d7a1c741fbacd87b494bff2568e9`

## Current Suitability Status

Provisional outcome: **Suitable with constraints (pending visual baseline comparison)**.

Rationale:

- Core render pipeline works for both templates.
- At least one symbol (`📞`) shows a likely glyph-support problem.
- Watermark/transformed layout needs visual pass/fail against browser print baseline before final sign-off.

## Stakeholder Visual Review Outcome

Review date: `2026-04-20`.

Outcome recorded from user review:

- Visual output is acceptable for current templates, excluding missing production mailshot assets in this spike context.
- Non-appearing special characters are acceptable for now.

Decision update:

- Suitability status is now **Accepted: suitable with constraints**.

## Constraints / Risks Identified

1. Emoji/supplementary symbols may not render reliably with default font setup.
2. CSS transform/fixed-position behavior is active but not yet visually validated for final layout fidelity.

## Required Next Validation

1. Generate browser print-to-PDF baseline for both sample templates.
2. Perform side-by-side visual check for:
   - watermark position/opacity/rotation
   - table borders and spacing
   - line wrapping and paragraph flow
   - logo placement
3. Decide whether to:
   - accept template constraints (for unsupported symbols), or
   - change fonts/renderer strategy.

## Rerun Record (Corrected invoicing template)

Rerun timestamp: `2026-04-20 14:05:44 BST`.

Reason:

- `samples/invoicing.html` was corrected after the initial run (original sample was malformed).

Updated artefact fingerprints:

- `working/dompdf/pdfs/invoicing.pdf`
  - sha256: `ef5f12648cd29fde01398efe81e4873ce70b273fe3587d3de56596740af6c765`
- `working/dompdf/pdfs/renewal_draft.pdf`
  - sha256: `b2d2babc4f6918db8067f02b9a81ca4d7eb0e9e25bbda8223b59ae0d433b869f`
- `working/dompdf/rendered_html/invoicing.rendered.html`
  - sha256: `2536cbc2eecfa6eb09ddc2c1832e2c2b8ae98200f42f31537182d3baf555845c`
- `working/dompdf/rendered_html/renewal_draft.rendered.html`
  - sha256: `b81b8fea7f07bcdf32667adc27f88cc060c1d7a1c741fbacd87b494bff2568e9`
