Convert PDF files to Markdown using LightOnOCR-2-1B, a state-of-the-art OCR model.
# Clone the repository
git clone https://github.com/cast42/pdf2md.git
cd pdf2md
# Install dependencies
just install
# Using just (recommended)
just pdf test.pdf
# Or using the CLI directly
uv run pdf2md test.pdf
# Specify custom output path
uv run pdf2md input.pdf -o output.md
$ just pdf document.pdf
Converting: document.pdf
Using device: mps with dtype torch.float32
✓ Model loaded successfully
✓ Loaded 5 page(s) from PDF
Processing page 5/5... ━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:23
✓ Saved markdown to document.md
This project uses modern Python tooling:
just # List all available commands
just pdf <file> # Convert PDF to Markdown
just test # Run tests
just lint # Run linter with auto-fix
just format # Format code
just typing # Run type checker
just check # Run all pre-commit hooks
just install # Install dependencies
just update # Update dependencies
just clean # Remove temporary files
just test
# Run all checks
just check
# Or individually
just lint
just typing
To enable cloud logging with Logfire:
.env.example to .envLOGFIRE_TOKEN=your-token-hereWithout a token, logging only appears in console output.
pypdfium2 to render PDF pages as images at 300 DPIMIT License - see LICENSE for details.
2 commits
Python
91.3%
Just
8.7%
Convert PDF files to Markdown using LightOnOCR-2-1B, a state-of-the-art OCR model.
# Clone the repository
git clone https://github.com/cast42/pdf2md.git
cd pdf2md
# Install dependencies
just install
# Using just (recommended)
just pdf test.pdf
# Or using the CLI directly
uv run pdf2md test.pdf
# Specify custom output path
uv run pdf2md input.pdf -o output.md
$ just pdf document.pdf
Converting: document.pdf
Using device: mps with dtype torch.float32
✓ Model loaded successfully
✓ Loaded 5 page(s) from PDF
Processing page 5/5... ━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:23
✓ Saved markdown to document.md
This project uses modern Python tooling:
just # List all available commands
just pdf <file> # Convert PDF to Markdown
just test # Run tests
just lint # Run linter with auto-fix
just format # Format code
just typing # Run type checker
just check # Run all pre-commit hooks
just install # Install dependencies
just update # Update dependencies
just clean # Remove temporary files
just test
# Run all checks
just check
# Or individually
just lint
just typing
To enable cloud logging with Logfire:
.env.example to .envLOGFIRE_TOKEN=your-token-hereWithout a token, logging only appears in console output.
pypdfium2 to render PDF pages as images at 300 DPIMIT License - see LICENSE for details.
2 commits
Python
91.3%
Just
8.7%