Skip to main content

This project contains a command line tool to convert PDF to markdown. It uses image conversion and a LLM to convert the images to markdown.

Project description

PDF to Markdown

This project contains a command line tool to convert PDF and Word documents to markdown. It uses image conversion and an LLM to convert the images to markdown.

Install

Execute these commands in the base directory of this project.

On Windows download the poppler library (e.g. poppler-24.08.0) from here and then do this using PowerShell:

$env:PKG_CONFIG_PATH="<download_folder>\poppler-24.08.0\Library\lib\pkgconfig"
# conda remove -n pdf_to_markdown --all
uv venv
# .venv\Scripts\activate
source .venv/bin/activate
uv sync
# Windows
pip install cmake
# End Windows
# Linux
sudo apt update
sudo apt install g++ -y
sudo apt install pkg-config -y
sudo apt-get install poppler-utils libpoppler-cpp-dev
# End Linux

There is an installation script for Linux in this repository.

Configuration

The application is configured used environment variables which you can set in an .env file. Check the .env_local file for the names of the variables that you will need.

You will need an Open AI key to run the PDF conversion.

You will also need a Gemini API key.

So you will need two environment variables:

OPENAI_API_KEY GEMINI_API_KEY

Usage of the command line application

Example: how to convert multiple pdf files with the OpenAI engine:

python ./pdf_to_markdown_llm/main/cli.py convert-files -f ./pdfs/oecd/002b3a39-en.pdf -f ./pdfs/oecd/ee6587fd-en.pdf

Example: how to convert a Word file to markdown with the OpenAI engine:

python ./pdf_to_markdown_llm/main/cli.py convert-files -f "./docs/Explainability March 2025.docx"

Example: how to convert a Word file to html with the OpenAI engine:

python ./pdf_to_markdown_llm/main/cli.py convert-files -f "./docs/bk/Pour INSCRIPTION en ligne MARCORIGNAN .docx" -t html

Example: how to convert a single file with Gemini model:

python ./pdf_to_markdown_llm/main/cli.py convert-files -f ./pdfs/oecd/002b3a39-en.pdf -e gemini

Example: how to convert all pdf files in a folder:

python ./pdf_to_markdown_llm/main/cli.py convert-in-dir --dirs ./pdfs/oecd

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdf_to_markdown_llm-0.1.12.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdf_to_markdown_llm-0.1.12-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file pdf_to_markdown_llm-0.1.12.tar.gz.

File metadata

File hashes

Hashes for pdf_to_markdown_llm-0.1.12.tar.gz
Algorithm Hash digest
SHA256 ac1aa5a140a92cb49140988ec32cec8cd65fbbcd742ff1bd8806646bca99e65e
MD5 5c7a6038de0d44c7e59e2bef04f64fc8
BLAKE2b-256 6f603886bdd37aee733a8e2b69e5d33f1b92193180d7b9085e72a95dd023ff08

See more details on using hashes here.

File details

Details for the file pdf_to_markdown_llm-0.1.12-py3-none-any.whl.

File metadata

File hashes

Hashes for pdf_to_markdown_llm-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 f2dbf78d763af836dbe895d9f2f620c4000fe40dd78d37974405949f71cd564b
MD5 bf11a28821dfa12c12843a70c64a3dba
BLAKE2b-256 7d853f37887d8ca71be452ec45b5da24020b4e2ec7d1b64da08db38f7f937a0d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page