Skip to content

jollyxenon/Pdf2Any

Repository files navigation

Pdf2Any

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.

Prerequisites

  • 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).

Setup & Installation

  1. Clone the repository:

    git clone <repo-url>
    cd Pdf2Any
  2. Install dependencies:

    pip install -r requirements.txt
  3. Configure Environment Variables: Copy .env.example to .env and 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.

Usage

🖥️ Local Web GUI (Gradio)

Run the script without arguments to start the user-friendly Gradio web application:

python main.py

⚡ Command Line Interface (CLI)

The 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.

Development & Testing

You can use pytest to validate the environment setup, API logic parsing, and core integrations.

pytest tests/ -v

License

MIT License.

About

A tool that can convert scanned PDF to other formats. Developed based on mineru and pandoc.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors