physnya/pdf2pdf

This is a personal project done by me and my codex. The purpose is to transfer academic articles into a more reading-friendly version for my e-ink device (my current one is Supernote A5X2 Manta).

★ 0Forks 0PythonGitHub ↗Compare

README

pdf2pdf

Rebuild research-paper PDFs as readable, one-column PDFs for the Supernote A5 X2 Manta. The output uses the Manta screen size, preserves equations and figures, removes page furniture, and leaves a right margin for handwritten notes.

The conversion pipeline is fully local after MinerU downloads its models:

PDF -> MinerU -> Markdown and assets -> Pandoc/XeLaTeX -> PDF

Requirements

  • macOS with the Palatino font
  • Python 3.11, 3.12, or 3.13
  • Pandoc
  • XeLaTeX

On macOS, Pandoc and XeLaTeX can be installed with Homebrew:

brew install pandoc
brew install --cask mactex-no-gui

Install

python3.13 -m venv .venv
. .venv/bin/activate
pip install -e .

MinerU may download several gigabytes of models on the first conversion.

Use

pdf2pdf article.pdf article-manta.pdf

The default output has 8 mm page margins and a 30 mm right notes margin. Both are adjustable:

pdf2pdf article.pdf article-manta.pdf \
  --page-margin-mm 8 \
  --notes-margin-mm 30

The converter is also available as a Python function:

from pdf2pdf import convert_pdf

convert_pdf("article.pdf", "article-manta.pdf")

Pass an object with an extract(input_pdf, output_dir) method to convert_pdf(..., extractor=...) to use another local or API-backed extractor.

Test

python -B tests/test_reflow.py

The test generates temporary synthetic PDFs and does not require bundled article files or OCR models.

Limits

OCR and formula recognition can make content mistakes. Very complex tables, multi-panel figures, and unusually long equations may require manual review.

AI Disclosure

This project was developed with assistance from OpenAI Codex. AI-generated changes were reviewed and tested before inclusion.

Contributors

physnya

Issues