Skip to content

ericceg/CroPDF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CroPDF

There is now a native MacOS version of CroPDF built with SwiftUI! Check it out under https://github.com/ericceg/CroPDF-MacOS.

License: MIT Python 3.8+ Platform Dependencies Size

CroPDF

Lightweight PDF cropper that keeps vector quality. Extract figures from textbooks for Typst, LaTeX, or any other document.

Why I Made This

I write my math notes in Typst and often want to include figures from textbooks (which I have as PDFs). To preserve the best possible quality (sharp text, scalable diagrams, no compression artifacts) I need to crop the original PDF and keep it in PDF format.

Yes, some PDF viewers can do this. But I wanted something:

  • Lightweight — no bloated software, just a simple tool
  • Fast — open, crop, save, done
  • Lossless — true vector output, not a rasterized screenshot

So I built CroPDF: ~280 lines of Python, one dependency, does one thing well.

Features

  • 📄 Vector-quality output — crops PDFs without rasterization
  • 🖱️ Visual selection — draw a rectangle to define the crop area
  • ⌨️ Pixel-perfect adjustment — fine-tune with arrow keys
  • 📖 Page navigation — browse multi-page PDFs easily
  • 💻 CLI launch options — convenient command-line usage
  • 🪶 Minimal footprint — just PyMuPDF

Installation

Prerequisites

Python 3.8+ is required. Install if needed:

  • macOS: brew install python (or download from python.org)
  • Windows: Download from python.org
  • Linux: Usually pre-installed, or sudo apt install python3

uv (recommended) — fast Python package installer:

curl -LsSf https://astral.sh/uv/install.sh | sh

Or see uv installation docs.

Quick Install (recommended)

uv tool install git+https://github.com/ericceg/CroPDF.git

Then run from anywhere:

cropdf

With pip

pip install git+https://github.com/ericceg/CroPDF.git

From Source

git clone https://github.com/ericceg/CroPDF.git
cd CroPDF
uv tool install .
# or: pip install .

Usage

cropdf

Or open a file directly:

cropdf path/to/file.pdf

Or open a file and jump to a page immediately (1-based):

cropdf path/to/file.pdf --page 12
  1. Run cropdf (or cropdf path/to/file.pdf)
  2. Navigate to the page with the figure you want
  3. Click and drag to draw a crop rectangle
  4. Fine-tune the selection:
    • Arrow keys — move the rectangle (1px)
    • Shift + Arrow — resize the rectangle
    • Space + Arrow — move/resize by 25px
  5. Click Crop and Save → choose output location

The output is a proper PDF — scalable, searchable, perfect for embedding.

Keyboard Shortcuts

Shortcut Action
⌘O / Ctrl+O Open PDF file
⌘S / Ctrl+S Crop and save
⌘G / Ctrl+G Go to page
Navigate pages (when no selection)
Arrow keys Move selection (1px)
Shift + Arrow Resize selection
Space + Arrow Move/resize by 25px
Escape Deselect area

Use Cases

  • 📚 Extract figures from textbooks for your notes
  • 📝 Include diagrams in Typst/LaTeX documents
  • 🎓 Crop theorems or examples for presentations
  • 📊 Pull charts from papers for slides

Requirements

  • Python 3.8+
  • tkinter (GUI library)

Note: tkinter is included with most Python installations. If you get ModuleNotFoundError: No module named '_tkinter':

  • macOS (Homebrew): brew install python-tk
  • Ubuntu/Debian: sudo apt-get install python3-tk
  • Windows: tkinter is included by default

License

MIT. See LICENSE.

About

Lightweight PDF cropper that keeps vector quality.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages