Automated PDF Compliance Test Harness
A two-check validation harness that tests generated PDF letters against layout and content rules, with per-file failure reasons and a colour-coded Excel report.
The Challenge
The harness's pass/fail verdicts matched the known answer for all 300 letters in a synthetic test corpus, with a specific reason logged for every failure.
Automated document generation can drift from its specification without raising an error: a missing field, a broken layout, a lost bold line. The question is not whether documents were generated, but whether they are compliant, and that needs a harness that defines compliance precisely, runs deterministically and reports at file level.
Why this matters in regulated settings: in financial services, insurance and legal work, document compliance is an audit obligation, and manual spot checks do not scale.
Why this matters for regulated environments: In financial services, insurance, and legal contexts, document compliance is not a cosmetic concern - it is an audit and regulatory obligation. Manual spot-checking at volume is statistically insufficient. Automated harnesses with quantified false-positive and false-negative rates are the only defensible approach.
Approach
Results
Every letter failed by the layout check was also failed by the content check: the layout check only fires when a defect removes a line, so it acts as a secondary safeguard rather than an independent detector.
Read with care: the corpus and the rules come from the same specification and only five defect types are seeded, so full agreement is expected by construction. It shows the harness works as designed, not how it would perform on real-world drift. An early version reported every later field as missing once one field was absent; this was fixed so that per-file reasons point to the actual defect.
Relevance to Production Contexts
The same pattern, parse, assert and report, applies to any document type whose rules can be written down: regulated notices, certificates, contracts or automated correspondence. Moving to production would mean testing against real generated output, adding defect types seen in practice and tracking false-alarm rates over time.
How it was tested
- 300 synthetic letters with a known answer for each: 210 valid, 90 with one seeded defect.
- Verdicts matched ground truth for all 300, reproduced in three runs.
- An early version reported every later field as missing once one field was absent. It was fixed so that per-file reasons point to the actual defect.
- The layout check only fires when a defect removes a line, so it acts as a secondary safeguard rather than an independent detector.
- The corpus and the rules come from the same specification and only five defect types are seeded, so full agreement is expected by construction.
- Not yet tested against real generated output or real-world drift.