CosmosShadow

gptpdf: Convert PDFs into Markdown with Vision Models

gptpdf turns PDF pages into Markdown using a vision-capable model, aiming to preserve layouts such as tables, formulas, and figures. It suits developers who need an API-based PDF parsing component and can provide access to a compatible model.

PythonMITAILLMLibrary
Stars
3.6k
Forks
261

Our take

Health score

25/100

How it is scored
Activity
20
Community
36
Issues
21
Pull requests
21

Overview

gptpdf is a Python library for converting PDF documents into Markdown with help from a multimodal language model. It uses PyMuPDF to identify non-text areas, then sends page content for model-based interpretation, including elements that ordinary text extraction may miss.

It is intended for developers who want to integrate structured PDF parsing into scripts or workflows. The approach relies on an external model API, so it makes most sense when visual interpretation matters and API access and per-page costs are acceptable.

Key Features

  • Converts PDF documents into Markdown and returns paths to extracted images.
  • Uses PyMuPDF to locate and mark non-text areas before model interpretation.
  • Supports multimodal models through an OpenAI-compatible API interface.
  • Allows configuration of the model, API base URL, and API key.
  • Accepts custom prompts for page content, marked regions, and the model's role.
  • Offers configurable worker threads for model parsing.
  • Includes example outputs and a Google Colab walkthrough.

Use Cases

  • Developers can turn research papers into Markdown for downstream processing when equations, tables, or figures need model interpretation.
  • Data and document teams can extract content from visually complex PDFs for internal search or analysis pipelines.
  • Researchers can produce editable Markdown drafts from papers while retaining references to extracted images.
  • Builders of PDF-processing tools can use the library as a parsing component and connect it to a compatible model service.

Getting Started

Install the package:

pip install gptpdf

See the README for usage, API options, and examples.

Alternatives

  • pdf-craft: pdf-craft focuses on OCR for scanned books and documents, and can export EPUB or translated output as well as Markdown.
  • docling: Docling handles PDFs and other formats with local processing and structured exports, rather than relying on a vision-model API.
  • marker: Marker processes PDFs and other documents locally into Markdown, JSON, HTML, or chunks using its inference backend.
  • text-extract-api: text-extract-api is a self-hostable service for PDFs, images, and Office files, with OCR, Ollama models, and PII removal.
ProjectLanguageLicenseStarsStatus
gptpdfPythonMIT3.6kNot checked yet
pdf-craftPythonMIT6.3kActive
doclingPythonMIT68.3kActive
markerPythonApache-2.040.2kActive
text-extract-apiPythonMIT3.2kQuiet

Considerations

  • Parsing requires access to a compatible multimodal model API and an API key or equivalent service configuration.
  • Model use can incur costs. The README estimates an average of $0.013 per page, which may vary with provider, model, and usage.
  • Output quality depends on the selected model and prompts. Review results when exact transcription or layout fidelity is important.
  • The repository describes a compact implementation, but the provided information does not establish guarantees for every PDF type or document layout.

Found this useful?

Share it with someone who would like gptpdf.

Comparisons