Skip to main content

PDF to Markdown parser using Datalab's Marker OCR API with optional GPT-based figure filtering

Project description

Chandra Parser

PDF to Markdown parser using Datalab's Marker OCR API with optional GPT-based figure filtering.

Built by ReSolve Asset Management to make financial research more accessible.

Why We Built This

At ReSolve, we produce extensive research on asset allocation, alternatives, and portfolio construction. We wanted a better way to:

  • Convert our PDF research papers into searchable, web-friendly markdown
  • Extract clean text for AI/LLM processing and RAG pipelines
  • Make our educational content more accessible across devices

We open-sourced this tool so others in the investment community can benefit too.

Try it on our research: Download any paper from Return Stacked ETFs or ReSolve Asset Management and parse it with Chandra.

Features

  • High-quality OCR: Uses Datalab's Marker API for accurate PDF text extraction
  • Paginated output: Splits documents into individual page files
  • Page images: Extracts PDF pages as PNG images at configurable resolution
  • Figure filtering: Optionally removes logos, decorations, and non-essential images using GPT
  • CLI & library: Use from command line or import as a Python package

Installation

# Using uv (recommended)
uv add chandra-parser

# Using pip
pip install chandra-parser

Quick Start

Command Line

# Parse a PDF
chandra parse document.pdf ./output

# Parse without figure filtering
chandra parse document.pdf ./output --no-filter

# Extract just the page images
chandra images document.pdf ./page_images --width 1024

Python API

from chandra_parser import parse_pdf

# Full pipeline
result = parse_pdf(
    "document.pdf",
    "./output",
    filter_figures=True,  # Requires OPENAI_API_KEY
    extract_images=True,
    image_width=712,
)

# Individual functions
from chandra_parser import extract_page_images, filter_pages

extract_page_images("document.pdf", "./images", width=712)

Configuration

Create a .env file or set environment variables:

# Required: Datalab API key
DATALAB_API_KEY=your_key_here

# Optional: For GPT-based figure filtering
OPENAI_API_KEY=your_key_here

Get your Datalab API key at datalab.to.

Output Structure

output/
├── final.md              # Cleaned, bound markdown (filtered if enabled)
├── output.md             # Raw OCR output
├── response.json         # Full API response
├── images/               # Extracted figures from OCR
├── page_images/          # PDF page renders as PNG
├── pages/                # Individual page markdown files
└── pages_filtered/       # Filtered page markdown (if filtering enabled)

macOS Quick Action (Right-Click to Parse)

Want to parse PDFs with a simple right-click? We have a step-by-step guide to set up a Finder Quick Action — no coding experience required.

View the Quick Action Setup Guide →

Once set up, just right-click any PDF and select "Parse PDF with Chandra". The output folder opens automatically when complete.

API Reference

parse_pdf(file_path, output_dir, **options)

Main entry point for parsing PDFs.

Arguments:

  • file_path: Path to the PDF file
  • output_dir: Directory for output files
  • filter_figures: Use GPT to remove non-essential figures (default: True)
  • extract_images: Extract PDF pages as PNG (default: True)
  • image_width: Width for page images in pixels (default: 712)
  • verbose: Print progress messages (default: True)

Returns: Path to the final markdown file

extract_page_images(pdf_path, output_dir, width=712)

Extract each page of a PDF as a PNG image.

filter_pages(input_dir, output_dir, batch_size=10, model="gpt-5-mini")

Filter non-essential figures from markdown pages using GPT.

About

Chandra Parser is developed and maintained by ReSolve Asset Management, a systematic asset manager specializing in risk parity, managed futures, and alternative investment strategies.

Learn more about our work:

License

MIT License - see LICENSE for details.

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

chandra_parser-0.1.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

chandra_parser-0.1.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file chandra_parser-0.1.0.tar.gz.

File metadata

  • Download URL: chandra_parser-0.1.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.2

File hashes

Hashes for chandra_parser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 57ed73c26f61ee7c8429f3170e929a3a39b44ac414e8b6019d808f31befe9c65
MD5 9e88b8b111289f3e2429ad9ca89d8d8c
BLAKE2b-256 916581f05a2a03d5be204fd50e5a6e9516f16c6c2eecbb8f00a69178acecf334

See more details on using hashes here.

File details

Details for the file chandra_parser-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for chandra_parser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79d6ff10f6535f5b5de8abcc49af581f501b20ec011cdaa7aba64a20f3dc7df3
MD5 4c2d19d0ecebc8be18213417f86c8adc
BLAKE2b-256 5ee8136d2e6ce9f96b63f8f5ee29a2d7887e6efabb747dab24a635fbf92bbbdd

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