Documentation Index
Fetch the complete documentation index at: https://mintlify.com/DilwoarH/pdf-visual-regression/llms.txt
Use this file to discover all available pages before exploring further.
Page count mismatches
When comparing PDFs with different numbers of pages, the tool handles this gracefully.Scenario: Extra pages in one PDF
Output behavior
Generated files
For extra pages, the tool saves snapshots with descriptive filenames:The tool compares pages up to the minimum page count, then separately captures any extra pages from the longer PDF.
Results JSON structure
Page size mismatches
The tool automatically handles PDFs with different page dimensions.How it works
From the source code (pdf_visual_diff.py:45-47):Why resize?
Why resize?
The Structural Similarity Index (SSIM) requires both images to have identical dimensions. The tool resizes the second PDF’s pages to match the first PDF’s dimensions using high-quality LANCZOS resampling.
Important considerations
Resizing can introduce minor visual artifacts. For best results, ensure both PDFs use the same page dimensions.
Tuning the similarity threshold
The SSIM threshold controls how sensitive the comparison is. The default is1.0 (exact match).
Understanding SSIM values
The Structural Similarity Index ranges from 0.0 to 1.0:- 1.0: Perfect match
- 0.999: Nearly identical (minor rendering differences)
- 0.95: Noticeable differences
- 0.5: Significant differences
- 0.0: Completely different
Adjusting sensitivity
When to adjust the threshold
Font rendering differences
Font rendering differences
Different systems may render fonts slightly differently. If you’re seeing false positives from font anti-aliasing, try
--threshold 0.999.PDF generation variations
PDF generation variations
Some PDF libraries introduce minor pixel differences even when content is identical. A threshold of
0.995 to 0.999 can help filter these out.Intentional visual changes
Intentional visual changes
Keep the default
1.0 threshold when you want to catch even the smallest visual differences during regression testing.Example: Filtering rendering artifacts
The threshold is applied per-page. Each page’s SSIM score must meet or exceed the threshold to be considered identical.
Combining multiple options
You can combine output directory and threshold settings:High-resolution rendering
The tool renders PDFs at 2x zoom (144 DPI) for better difference detection:Batch testing workflow
For CI/CD pipelines, you might want to test multiple PDF pairs:Exit codes
Exit codes
The tool doesn’t currently return specific exit codes for failures. Check the
results.json file’s status field to determine test outcomes programmatically.