Skip to content
pdf-parity-checker logo

PDF Parity Checker Skill

pdf-parity-checker

Verify visual and structural parity between XHTML chapters and POD PDF files. Use to ensure print edition matches digital EPUB layout.

mattnigh/skills_collection0installs24stars

SKILL.md

Full skill instructions

PDF Parity Checker Skill

Purpose

Compare the 44 XHTML chapter files against their corresponding POD (print-on-demand) PDF files to ensure visual and structural consistency. This is critical for maintaining brand quality across digital and print editions.

When to Invoke

  • User asks "do the PDFs match the EPUB chapters?"
  • Before sending POD files to IngramSpark or print vendor
  • After making changes to XHTML or CSS
  • User mentions "print edition" or "PDF consistency"
  • User asks "verify the PDFs are up to date"

Workflow

Run PDF Parity Verification

python3 scripts/​pdf_verify.py \
  --root REBRANDED_OUTPUT \
  --targets docs/​REBRANDED_VISUAL_AUDIT.json \
  --update-json

What it does:

  1. For each of the 44 XHTML files:
    • Locates corresponding PDF in REBRANDED_OUTPUT/​pdf-pod/
    • Compares:
      • Page count (XHTML rendered vs PDF pages)
      • Media box dimensions (PDF page size)
      • First-page visual hash (downscaled grayscale comparison)
      • Text extraction and paragraph continuity
  2. If PDF is missing:
    • Generates temporary reference PDF via headless browser print-to-PDF
    • Uses this for comparison (but does NOT commit to repo)
    • Flags as "MISSING" in report
  3. Updates docs/​REBRANDED_VISUAL_AUDIT.json with:
    • pdf_check object for each chapter
    • Fields: page_count_match, bbox_match, image_hash_delta, pdf_status

Comparison Metrics

1. Page Count Match

Compares rendered XHTML page count vs PDF page count.

Example:

Chapter IX: "Unveiling Your Creative Odyssey"
- XHTML rendered: 8 pages (at 6×9" print size)
- PDF actual: 8 pages
- Status: ✅ MATCH

Acceptable variance:

  • Exact match: ✅ PASS
  • ±1 page: ⚠️ WARN (minor reflow difference)
  • ±2+ pages: ❌ FAIL (significant layout mismatch)

2. Media Box (Page Size)

Verifies PDF pages are correct physical dimensions.

Expected for 6×9" POD:

  • Width: 432 points (6 inches × 72 DPI)
  • Height: 648 points (9 inches × 72 DPI)

Example:

Chapter XV: Media box check
- Expected: 432×648 pt
- Actual: 432×648 pt
- Status: ✅ MATCH

3. Visual Hash Comparison

Computes perceptual hash of first page to detect visual differences.

Process:

  1. Render XHTML first page as PNG (grayscale, downscaled to 200×300)
  2. Convert PDF first page to PNG (same size)
  3. Compute average hash for both
  4. Calculate Hamming distance

Scoring:

  • Hash delta 0-5: ✅ IDENTICAL (perfect match)
  • Hash delta 6-15: ✅ SIMILAR (acceptable variance)
  • Hash delta 16-30: ⚠️ DIFFERENT (minor layout shift)
  • Hash delta >30: ❌ MISMATCH (significant visual difference)

Example:

Chapter IV: Visual hash comparison
- XHTML hash: d4a3f2c1...
- PDF hash: d4a3f2c1...
- Hamming distance: 3
- Status: ✅ IDENTICAL

4. Text Extraction

Extracts text from PDF and verifies key content is present.

Checks:

  • Chapter title appears in first 500 characters
  • Heading order matches XHTML heading structure
  • Paragraph count is similar (±10%)

Example:

Chapter XII: Text extraction
- Title found: ✅ "Financial Wisdom"
- Headings: 12 in XHTML, 12 in PDF ✅
- Paragraphs: 84 in XHTML, 83 in PDF ✅ (within 10%)
- Status: ✅ PASS

Interpreting Results

JSON Output Structure

{
  "file": "REBRANDED_OUTPUT/​xhtml/​9-chapter-i-unveiling-your-creative-odyssey.xhtml",
  "basename": "9-chapter-i-unveiling-your-creative-odyssey",
  "pdf_check": {
    "pdf_path": "REBRANDED_OUTPUT/​pdf-pod/​chapters/​9-chapter-i-unveiling-your-creative-odyssey.pdf",
    "pdf_status": "ok",
    "page_count_match": true,
    "page_count_xhtml": 8,
    "page_count_pdf": 8,
    "bbox_match": true,
    "bbox_expected": [432, 648],
    "bbox_actual": [432, 648],
    "image_hash_delta": 3,
    "image_hash_verdict": "identical",
    "text_checks": {
      "title_found": true,
      "heading_count_match": true,
      "paragraph_variance_pct": 1.2
    }
  }
}

Markdown Summary

Generated in docs/​REBRANDED_VISUAL_AUDIT.md:

FilePDF StatusPage MatchVisual MatchIssues
9-chapter-i-...✅ OK✅ 8 pages✅ IdenticalNone
15-chapter-vi-...⚠️ OK⚠️ 10 vs 11✅ Similar+1 page variance
22-chapter-xii-...❌ MISSINGN/​AN/​APDF not found

Common Issues and Fixes

Issue: Page Count Mismatch

Symptom: XHTML renders as 8 pages, PDF has 9 pages

Possible causes:

  1. Extra blank page in PDF (page break issue)
  2. Different margin settings between XHTML and PDF export
  3. Widow/​orphan control differences

How to fix:

  1. Open PDF in Acrobat to verify blank page
  2. Adjust print-pod.css orphans/​widows settings:
    p { orphans: 2; widows: 2; }
    
  3. Re-export PDF from InDesign or print-to-PDF workflow
  4. Re-run parity check to verify

Issue: Visual Hash Mismatch

Symptom: Hash delta >30 (significant visual difference)

Possible causes:

  1. Font substitution in PDF vs XHTML
  2. Image resolution difference
  3. Different CSS applied (print vs digital styles)

How to fix:

  1. Open both side-by-side:
    • XHTML screenshot: docs/​screenshots/​{basename}/​title_1080x1440.png
    • PDF page 1: Open in Acrobat, export as PNG
  2. Identify visual difference (typography, spacing, images)
  3. Adjust print-pod.css to match digital rendering
  4. Regenerate PDF
  5. Re-run parity check

Issue: Missing PDF

Symptom: pdf_status: "missing"

Action:

  1. Check if PDF was not generated yet for this chapter
  2. Verify PDF naming matches XHTML basename:
    • XHTML: 9-chapter-i-unveiling-your-creative-odyssey.xhtml
    • PDF should be: 9-chapter-i-unveiling-your-creative-odyssey.pdf
  3. If PDF exists with different name, rename to match
  4. If PDF doesn't exist:
    • Generate from XHTML using print-to-PDF workflow
    • Place in appropriate pdf-pod/ subdirectory

Issue: Text Extraction Failure

Symptom: text_checks.title_found: false

Possible causes:

  1. PDF is image-only (scanned, not text-based)
  2. PDF has font embedding issues (text not extractable)
  3. PDF was generated with text as outlines/​curves

How to fix:

  1. Verify PDF is text-based (select text in Acrobat)
  2. If image-only, regenerate PDF from source XHTML
  3. Ensure fonts are embedded as subsets (not outlines)

Example Invocation

User: "Are the print PDFs in sync with the latest EPUB chapters?"

Agent response:

  1. Run PDF parity checker
  2. Read results from updated JSON
  3. Summarize:
PDF Parity Check Complete
=========================

Total chapters: 44
PDFs verified: 42
Missing PDFs: 2

Results:
✅ PASS: 38 chapters (perfect parity)
⚠️ WARN: 4 chapters (minor variance)
❌ FAIL: 0 chapters (significant mismatch)
🔍 MISSING: 2 chapters (PDFs not found)

Warnings (4 chapters):
- Chapter VI: +1 page variance (11 vs 10) - Extra blank page in PDF
- Chapter XI: Visual hash delta 18 - Minor font rendering difference
- Chapter XV: Text variance 12% - Some paragraphs reflowed
- Chapter XXII: Media box 432×660 - Height should be 648

Missing PDFs (2 chapters):
- 30-SelfAssessment.xhtml (no matching PDF found)
- 43-DoodlePage.xhtml (no matching PDF found)

Recommended actions:
1. Fix page break in Chapter VI
2. Review font settings for Chapter XI
3. Generate missing PDFs for Self-Assessment and Doodle pages
4. Verify media box for Chapter XXII

Full report: docs/​REBRANDED_VISUAL_AUDIT.md (PDF Parity column)
Detailed JSON: docs/​REBRANDED_VISUAL_AUDIT.json (pdf_check objects)

Integration with Other Skills

Run after:

  • epub-visual-auditor - Ensure XHTML rendering is correct first

Run before:

  • Sending POD files to print vendor
  • Uploading to IngramSpark or KDP Print
  • Final publication package

Pair with:

  • epub-publication-validator - Comprehensive pre-publication check

Notes

  • PDF comparison requires pypdf and Pillow Python libraries
  • First run may be slower (generates temporary PDFs for missing files)
  • Temporary reference PDFs are stored in /​tmp/ and not committed to repo
  • Visual hash comparison is perceptual (small rendering differences are OK)
  • Re-run after any CSS or XHTML changes to verify parity maintained

More skills from mattnigh

spring-framework-patterns logo
mattnigh/skills_collection

spring-framework-patterns

Comprehensive Spring Framework and Spring Boot best practices including dependency injection patterns, bean lifecycle and scopes, REST API development, Spring Data JPA, service layer design, Spring Security, testing strategies, caching, AOP, async processing, error handling, and common anti-patte...

24 0
View

TypeScript厳格モードによる型安全性設計を専門とするスキル。 📖 参照書籍: - 『Effective TypeScript』(Dan Vanderkam): 型設計 📚 リソース参照: - `resources/Level1_basics.md`: レベル1の基礎ガイド - `resources/Level2_intermediate.md`: レベル2の実務ガイド - `resources/Level3_advanced.md`: レベル3の応用ガイド - `resources/Level4_expert.md`: レベル4の専門ガイド - `resources/di...

24 0
View
deploying-cloud-k8s logo
mattnigh/skills_collection

deploying-cloud-k8s

Deploys applications to cloud Kubernetes (AKS/GKE/DOKS) with CI/CD pipelines. Use when deploying to production, setting up GitHub Actions, troubleshooting deployments. Covers build-time vs runtime vars, architecture matching, and battle-tested debugging.

24 0
View
moai-alfred-agent-guide logo
mattnigh/skills_collection

moai-alfred-agent-guide

19-agent team structure, decision trees for agent selection, Haiku vs Sonnet model selection, and agent collaboration principles. Use when deciding which sub-agent to invoke, understanding team responsibilities, or learning multi-agent orchestration.

24 0
View
mermaid-diagram-generator logo
mattnigh/skills_collection

mermaid-diagram-generator

Converts architecture descriptions, module specs, or workflow docs into Mermaid diagrams. Use when visualizing brick module relationships, workflows (DDD, investigation), or system architecture. Supports: flowcharts, sequence diagrams, class diagrams, state machines, entity relationship diagrams,...

24 0
View
pre-flight-check logo
mattnigh/skills_collection

pre-flight-check

INVOKE FIRST before any code work. Validates git workflow (branch, issue, worklog) and checks approach. Use at START of every task and END before completing. Prevents skipped steps.

24 0
View
browser-dev-tools logo
mattnigh/skills_collection

browser-dev-tools

This skill should be used when working with browser-rendered artifacts (i.e. Bun, React/React Native) to proactively validate that development work on localhost is being built appropriately and to support debugging browser-rendered content. Use this skill after making frontend changes to verify t...

24 0
View
lead-dev logo
mattnigh/skills_collection

lead-dev

Lead Développeur - Coordination technique opérationnelle, code review, mentoring et livraison. Pair de web-dev-process au niveau OPÉRATIONS.

24 0
View
worker-monitor logo
mattnigh/skills_collection

worker-monitor

Monitor Docker workers, RQ queue health, and auto-scale workers (max 4). Use when: checking job progress, monitoring queue depth, scaling workers up/down, diagnosing slow processing, or waiting for jobs to complete. Referenced by data-quality skill during reprocessing.

24 0
View
quality-advisor logo
mattnigh/skills_collection

quality-advisor

Proactive quality guidance system that monitors artifact creation and provides real-time feedback on documentation quality

24 0
View
bump-version logo
mattnigh/skills_collection

bump-version

This skill should be used when the user wants to bump the version number in the workspace. It updates versions across all pyproject.toml files (root, tde, and tda packages) and the CHANGELOG.md to keep them synchronized.

24 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View