Pdf2Any is a plug-and-play batch processing tool that leverages the high-precision MinerU API for PDF parsing and Pandoc for multi-format output compilation. It supports converting PDF documents to EPUB, DOCX, Markdown, LaTeX, and HTML.
- Python 3.8+
- Pandoc: Must be installed and available in your system's
PATH. - LaTeX Engine (Optional): If you plan on outputting to PDF format, ensure you have a standard LaTeX distribution installed (e.g., TeXLive or MiKTeX).
-
Clone the repository:
git clone <repo-url> cd Pdf2Any
-
Install dependencies:
pip install -r requirements.txt
-
Configure Environment Variables: Copy
.env.exampleto.envand fill in your MinerU API Token:cp .env.example .env
Edit
.env:MINERU_API_TOKEN=your_actual_mineru_api_token
MinerU API is free for all users. Obtain it via MinerU API Manage.
Run the script without arguments to start the user-friendly Gradio web application:
python main.pyThe tool serves as a powerful batch processor directly from the CLI.
Basic Multi-file Epub Usage:
python main.py -i file1.pdf file2.pdf -o ./output/Advanced Usage:
# Output multiple formats simultaneously, offline pandoc mode, and custom API-key
python main.py -i input.pdf -o ./output/ -f epub md docx --network offline --formula text --api-key <YOUR_TOKEN>Run python main.py -h for full commands list.
You can use pytest to validate the environment setup, API logic parsing, and core integrations.
pytest tests/ -vMIT License.