agentsclimarketplace

Cli opendataloader pdf

Skill DimkaGorhover/agent-skills/skills/cli-opendataloader-pdf

Use when converting PDF files to text, markdown, HTML, or JSON using opendataloader-pdf — extracting content for RAG pipelines, chunking for vector stores, handling encrypted PDFs, or processing multi-column/table-heavy documents.From its SKILL.md

Install
npx -y skills add DimkaGorhover/agent-skills --skill cli-opendataloader-pdf

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

13.6 KB, as published. Nobody here has run it

opendataloader-pdf

Overview

opendataloader-pdf is a CLI tool for structured PDF extraction optimized for RAG pipelines. It preserves reading order, bounding boxes, and semantic structure. Always run via uvx opendataloader-pdf ... — never install globally. Each invocation starts a JVM (~1–2 s); always batch multiple files in a single call.

When to Use

  • Converting PDFs to markdown, JSON, text, or HTML for LLM ingestion
  • Building RAG pipelines that need bounding boxes for precise citations
  • Processing multi-column academic papers, table-heavy financial reports, or legal documents
  • Batch converting folders of PDFs efficiently
  • Handling encrypted, tagged, or scanned (hybrid) PDFs

When NOT to Use

  • Creating, editing, or signing PDFs — use a PDF authoring library instead
  • Pure OCR of scanned images with no text layer — use a dedicated OCR tool (e.g., Tesseract)
  • Extracting only PDF metadata (author, title) — lighter tools suffice
  • Simple text extraction where reading order doesn't matter — pdftotext (poppler) or pypdf have less overhead

Quick Reference

OptionShortDefaultDescription
--output-dir-oinput dirDirectory for output files
--format-fjsonOutput formats (comma-separated): json, text, html, markdown, markdown-with-html, markdown-with-images, tagged-pdf
--password-p—Password for encrypted PDFs
--quiet-qfalseSuppress console logging
--pages—allPages to extract, e.g. "1,3,5-7"
--to-stdout—falseWrite to stdout (single format only)
--reading-order—xycutReading order algorithm: off, xycut
--use-struct-tree—falseUse PDF structure tree (tagged PDFs)
--table-method—defaultTable detection: default (border-based), cluster (border + cluster)
--keep-line-breaks—falsePreserve original line breaks
--replace-invalid-chars—spaceReplacement for unrecognized characters (default: single space " ")
--sanitize—falseRedact emails, phones, IPs, credit cards, URLs
--content-safety-off——Disable filters: all, hidden-text, off-page, tiny, hidden-ocg
--include-header-footer—falseInclude page headers/footers
--detect-strikethrough—falseDetect strikethrough (~~text~~ in markdown, <del> in HTML)
--image-output—externalImage mode: off, embedded (Base64), external (files)
--image-format—pngImage format: png, jpeg
--image-dir——Directory for extracted images
--markdown-page-separator—nonePage separator in markdown; use %page-number%
--text-page-separator—nonePage separator in text output
--html-page-separator—nonePage separator in HTML output

Hybrid (AI backend) options

OptionDefaultDescription
--hybridoffBackend: off, docling-fast (requires running server)
--hybrid-modeautoTriage: auto (dynamic), full (all pages to backend)
--hybrid-url—Remote backend URL
--hybrid-timeout0Request timeout in ms (0 = no timeout)
--hybrid-fallbackfalseFallback to Java on backend error

Common Recipes

Basic conversion

uvx opendataloader-pdf document.pdf -o ./output -f json,markdown

Batch folder (single JVM — fast)

uvx opendataloader-pdf ./pdf-folder -o ./output -f json,markdown

Multiple specific files

uvx opendataloader-pdf report1.pdf report2.pdf report3.pdf -o ./output -f json,markdown

Encrypted PDF

uvx opendataloader-pdf encrypted.pdf -p mypassword -o ./output

Specific pages only

uvx opendataloader-pdf document.pdf --pages "1,3,5-7" -f markdown -o ./output

Stdout (pipe-friendly)

uvx opendataloader-pdf document.pdf -f markdown --to-stdout | my-pipeline

Tagged/structured PDF

uvx opendataloader-pdf document.pdf --use-struct-tree -f json -o ./output

Page separators

uvx opendataloader-pdf document.pdf -f markdown --markdown-page-separator "--- Page %page-number% ---"

Disable reading order (pre-sorted PDFs)

uvx opendataloader-pdf document.pdf -f json --reading-order off

RAG Pipeline Integration

Recommended formats

FormatUse Case
markdownSimple text chunking/embedding (smallest output)
jsonStructured data with bounding boxes for citations
json,markdownBoth (recommended — use JSON for metadata, markdown for text)

JSON output structure

JSON keys use space-separated names (verified against official schema):

import json

with open("output/document.json", encoding="utf-8") as f:
    doc = json.load(f)

# Root fields: "file name", "number of pages", "kids"
for element in doc["kids"]:
    element_type = element["type"]  # "paragraph", "heading", "list", "table", "image"
    text = element.get(
        "content", ""
    )  # present on paragraph, heading, caption, list item
    page = element.get("page number")  # integer, 1-indexed
    bbox = element.get("bounding box")  # [left, bottom, right, top]

Chunking strategies

Merged chunks — minimum size (most practical for RAG, reduces noise):

def chunk_with_min_size(doc, min_chars=200):
    chunks, buffer_text, buffer_pages = [], "", []
    for element in doc["kids"]:
        if element["type"] in ("paragraph", "heading", "list"):
            buffer_text += element.get("content", "") + "\n"
            page = element.get("page number")
            if page and page not in buffer_pages:
                buffer_pages.append(page)
            if len(buffer_text) >= min_chars:
                chunks.append(
                    {
                        "text": buffer_text.strip(),
                        "metadata": {"pages": buffer_pages.copy()},
                    }
                )
                buffer_text, buffer_pages = "", []
    if buffer_text.strip():
        chunks.append(
            {"text": buffer_text.strip(), "metadata": {"pages": buffer_pages}}
        )
    return chunks

By semantic element (fine-grained retrieval, precise citations):

def chunk_by_element(doc):
    return [
        {
            "text": el.get("content", ""),
            "metadata": {
                "type": el["type"],
                "page": el.get("page number"),
                "bbox": el.get("bounding box"),
                "source": doc.get("file name"),
            },
        }
        for el in doc["kids"]
        if el["type"] in ("paragraph", "heading", "list")
    ]

By section heading (context-rich, topic-based):

def chunk_by_section(doc):
    chunks, heading, content, start_page = [], None, [], None
    for el in doc["kids"]:
        if el["type"] == "heading":
    if content and len(content) > 1:
                chunks.append(
                    {
                        "text": "\n".join(content),
                        "metadata": {"heading": heading, "page": start_page},
                    }
                )
            heading, content, start_page = (
                el.get("content", ""),
                [el.get("content", "")],
                el.get("page number"),
            )
        elif el["type"] in ("paragraph", "list") and el.get("content"):
            content.append(el["content"])
    if content:
        chunks.append(
            {
                "text": "\n".join(content),
                "metadata": {"heading": heading, "page": start_page},
            }
        )
    return chunks

Precise citations from bounding boxes

def format_citation(metadata):
    citation = f"Source: {metadata.get('source', 'unknown')}"
    if metadata.get("page"):
        citation += f", Page {metadata['page']}"
    if metadata.get("bbox"):
        bbox = metadata["bbox"]
        citation += f", Position ({bbox[0]:.0f}, {bbox[1]:.0f})"
    return citation


# Output: "Source: document.pdf, Page 3, Position (72, 450)"

LangChain integration

Use a PEP 723 inline script header so the script is self-contained — no manual pip install or venv setup required:

#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = [
#     "langchain-opendataloader-pdf",
# ]
# ///

from langchain_opendataloader_pdf import OpenDataLoaderPDFLoader

loader = OpenDataLoaderPDFLoader(
    file_path=["document.pdf", "folder/"],
    format="text",
    quiet=True,
)
documents = loader.load()

Run with:

uv run script.py

Document Type Recommendations

Document TypeRecommended Flags
Academic papers (multi-column)default (XY-Cut handles columns)
Financial reports (table-heavy)-f json (preserves row/column structure)
Legal documents (long text)-f markdown
Tagged/accessible PDFs--use-struct-tree
Scanned/complex layout--hybrid docling-fast

Common Mistakes

MistakeFix
Running opendataloader-pdf directlyAlways use uvx opendataloader-pdf ...
One file per call in a loopPass all files/folder in a single call (one JVM)
Using --content-safety-off all for RAGKeep safety filters on — they remove headers, watermarks, hidden text that pollute chunks
Using markdown when you need citationsUse json or json,markdown to get bounding boxes
Tables losing structure in markdownUse -f json for table-heavy documents
Too many tiny chunksUse chunk_with_min_size(doc, min_chars=500)
Forgetting -q in automated pipelinesAdd --quiet to suppress JVM logging noise

Keep looking

Skills are one crate of 607,533. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.