Skip to content

feat(compare): add PDF file comparison support#63

Merged
MrFlounder merged 1 commit intomainfrom
feat/compare-pdf-support
Mar 14, 2026
Merged

feat(compare): add PDF file comparison support#63
MrFlounder merged 1 commit intomainfrom
feat/compare-pdf-support

Conversation

@MrFlounder
Copy link
Contributor

Summary

  • Adds PDF comparison support to crab compare by extracting text via pdftotext (poppler) before diffing
  • Detects .pdf extensions (case-insensitive) and auto-extracts text with layout preservation
  • Shows platform-specific install instructions if pdftotext is missing (brew/apt/dnf)
  • Warns when both PDFs produce empty text (scanned/image-based PDFs)
  • Prevents comparing a PDF against a non-PDF file

Test plan

  • crab compare file1.pdf file2.pdf — opens diff in browser with extracted text
  • crab compare file.pdf file.txt — shows error about mismatched types
  • crab compare file1.txt file2.txt — still works as before (no regression)
  • Without pdftotext installed — shows install instructions
  • With identical PDFs — shows "Files are identical"

🤖 Generated with Claude Code

Extract text from PDFs using pdftotext before diffing, enabling
side-by-side comparison of PDF documents in the browser viewer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MrFlounder MrFlounder merged commit b27e82b into main Mar 14, 2026
5 checks passed
@MrFlounder MrFlounder deleted the feat/compare-pdf-support branch March 14, 2026 03:10
MrFlounder added a commit that referenced this pull request Mar 14, 2026
## Summary
- Adds `compare_ensure_poppler` helper that auto-installs poppler when
missing (brew/apt/dnf)
- Runs during first-time asset setup (`compare_ensure_assets`) so PDF
comparison works out of the box
- Also runs on `crab compare --update-assets` to ensure poppler is
present
- Falls back to a manual install message if no supported package manager
is found

Follow-up to #63.

## Test plan
- [ ] On a machine without poppler: `crab compare file1.pdf file2.pdf` —
auto-installs poppler then compares
- [ ] `crab compare --update-assets` — re-downloads assets and ensures
poppler is installed
- [ ] On a machine with poppler already installed — skips install
silently

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant