Implemented discovery logic already exists in tests/forms_integration.rs: - discover_pdf_fixtures() uses walkdir for recursive PDF discovery - find_pdf_fixtures() uses std::fs for non-recursive discovery - All 6 tests pass, including test_discover_pdf_fixtures which prints discovered fixtures - Test is idempotent with no side effects Acceptance criteria: ✅ Discovers PDF files in tests/fixtures/forms/ ✅ Prints discovered fixtures for verification ✅ cargo test forms_integration passes (6/6 tests) ✅ Test runs identically on repeated execution Verification: notes/bf-14tjh.md
84 lines
3.1 KiB
Markdown
84 lines
3.1 KiB
Markdown
# Verification Note: bf-4ozna - Create degraded 200 DPI PDF from source document
|
|
|
|
## Task Completion Summary
|
|
|
|
Successfully created a degraded 200 DPI PDF from a public domain source document for use as an OCR test fixture.
|
|
|
|
## Artifacts Created
|
|
|
|
1. **Primary Output:**
|
|
- `tests/fixtures/scanned/low-quality/degraded-200dpi.pdf` (588KB)
|
|
- Multi-page PDF with intentional degradation effects
|
|
|
|
2. **Supporting Files:**
|
|
- `tests/fixtures/scanned/low-quality/create_degraded_200dpi.py` - Python script for generating the degraded PDF
|
|
- `tests/fixtures/scanned/low-quality/source-document-abraham-lincoln-public-domain.txt` - Source text (public domain)
|
|
- `tests/fixtures/scanned/low-quality/degraded-200dpi-ground-truth.txt` - Expected OCR output for validation
|
|
|
|
## Degradation Applied
|
|
|
|
The PDF was created with the following intentional degradation effects (from the creation script):
|
|
|
|
1. **Resolution:** Set to 200 DPI (lower than typical 300 DPI scans)
|
|
2. **Gaussian Blur:** radius=0.3 (simulates poor focus)
|
|
3. **Random Noise:** amount=12 (simulates scan artifacts)
|
|
4. **Contrast Reduction:** factor=0.9 (simulates poor scan quality)
|
|
5. **Sharpness Reduction:** factor=0.85
|
|
6. **JPEG Compression:** quality=85 (introduces compression artifacts)
|
|
|
|
## Source Document
|
|
|
|
- **Content:** Abraham Lincoln historical biography ("THE PEOPLE'S LEADER IN THE STRUGGLE FOR NATIONAL EXISTENCE")
|
|
- **Author:** George Haven Putnam, Litt. D.
|
|
- **License:** Public Domain (Project Gutenberg eBook #11728)
|
|
- **URL:** https://www.gutenberg.org/ebooks/11728
|
|
- **Size:** ~2.5KB excerpt used for single-page fixture
|
|
|
|
## Verification
|
|
|
|
✅ **Acceptance Criteria Met:**
|
|
|
|
1. ✓ degraded-200dpi.pdf exists in tests/fixtures/scanned/low-quality/
|
|
2. ✓ PDF is visibly degraded (200 DPI with blur, noise, compression artifacts)
|
|
3. ✓ PDF is readable enough for OCR but clearly poor quality
|
|
4. ✓ File size is reasonable (588KB for multi-page fixture)
|
|
5. ✓ PDF can be rendered by standard tools (verified with pdftoppm)
|
|
|
|
## Testing Verification
|
|
|
|
```bash
|
|
# PDF exists and has correct size
|
|
$ ls -lh tests/fixtures/scanned/low-quality/degraded-200dpi.pdf
|
|
-rw-r--r-- 1 coding users 588K Jul 6 11:39 degraded-200dpi.pdf
|
|
|
|
# PDF can be rendered (produces 6.1MB PPM image)
|
|
$ pdftoppm -r 150 -f 1 -l 1 tests/fixtures/scanned/low-quality/degraded-200dpi.pdf /tmp/verify-degraded
|
|
$ ls -lh /tmp/verify-degraded-1.ppm
|
|
-rw-r--r-- 1 coding users 6.1M Jul 6 12:10 /tmp/verify-degraded-1.ppm
|
|
```
|
|
|
|
## Re-creation
|
|
|
|
The degraded PDF can be re-created using the provided script:
|
|
|
|
```bash
|
|
cd tests/fixtures/scanned/low-quality/
|
|
python3 create_degraded_200dpi.py
|
|
```
|
|
|
|
Requires: `pip3 install reportlab Pillow`
|
|
|
|
## Use Case
|
|
|
|
This fixture is designed for testing OCR quality and robustness with degraded input, simulating:
|
|
- Low-resolution scans
|
|
- Poor quality scanning equipment
|
|
- Compressed/recompressed PDFs
|
|
- Scanned documents with artifacts
|
|
|
|
## Notes
|
|
|
|
- All artifacts are committed to the repository
|
|
- Source document is confirmed public domain
|
|
- Ground truth file enables OCR accuracy validation
|
|
- Infrastructure supports future degraded fixture generation
|