Use when generated PDFs (invoices, contracts, regulatory filings) must not shift layout, or a template, font or PDF library is changing. Renders pages to images and pixel-diffs them against approved baselines, strips volatile metadata, and compares HTML-to-PDF engines.
91%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Non-deterministic PDF metadata and host font substitution are the two environment factors that invalidate baselines. Normalize both before diffing, or rely on image diff (which is metadata-free by construction).
PDFs include /CreationDate, /ID, sometimes /ModDate. These change
per run and break byte diffs. Use qpdf to normalize:
qpdf --linearize \
--object-streams=disable \
--replace-stream-data=uncompress \
--remove-attachments \
out.pdf normalized.pdfAlternative: rely on image diff (render + pixel-diff) which is metadata-free by construction.
Missing fonts on the rendering host produce visually-different output. Detect via Poppler stderr:
import subprocess
result = subprocess.run(
["pdfinfo", "-list-embedded-fonts", "out.pdf"],
capture_output=True, text=True,
)
if "Font Substitution" in result.stderr:
raise RuntimeError("Font substitution detected; baseline invalid")For CI, install the production font pack via the package manager or check fonts into the repo for deterministic builds.