PDF解析工具,专为AI/RAG设计。支持将PDF转换为Markdown、JSON、HTML,保留布局、边界框和图片提取,适用于需要提取的场景。
PDF parsing tool for AI/RAG scenarios. Converts PDF to Markdown, JSON, HTML with layout preservation.
bash
pipx install opendataloader-pdf
Requires Java runtime (bundled JAR is included).
bash
# PDF to Markdown (most common)
opendataloader-pdf input.pdf -o output_dir -f markdown
# PDF to JSON (with bounding boxes)
opendataloader-pdf input.pdf -o output_dir -f json
# Multiple formats at once
opendataloader-pdf input.pdf -o output_dir -f json,markdown,html
# Extract specific pages
opendataloader-pdf input.pdf -o output_dir -f markdown --pages "1,3,5-10"
# Extract images
opendataloader-pdf input.pdf -o output_dir -f markdown --image-dir images/
# Use PDF structure tree (for tagged PDFs)
opendataloader-pdf input.pdf -o output_dir -f markdown --use-struct-tree
# Output to stdout
opendataloader-pdf input.pdf -f markdown --to-stdout
FormatDescriptionjsonStructured JSON with bounding boxes, fonts, reading ordermarkdownMarkdown text with images as referenceshtmlHTML with stylingtextPlain textpdfRebuilt PDFmarkdown-with-htmlMarkdown with HTML for complex elementsmarkdown-with-imagesMarkdown with embedded base64 images
OptionDescription--pagesPage range, e.g., "1,3,5-10"--image-dirDirectory for extracted images--use-struct-treeUse PDF structure tree for reading order--table-methodTable detection: default (border-based) or cluster``--reading-orderAlgorithm: off or xycut (default)--hybridHybrid AI mode: docling-fast for complex tables--sanitizeRemove sensitive data (emails, phones, etc.)--include-header-footerInclude page headers/footers
bash
# Convert to markdown
opendataloader-pdf document.pdf -o ./output -f markdown
# Convert to JSON with structure
opendataloader-pdf document.pdf -o ./output -f json --use-struct-tree
bash
# Multiple files
opendataloader-pdf "file1.pdf" "file2.pdf" "folder/" -o output/
# All PDFs in directory
opendataloader-pdf ./pdfs/ -o ./output/ -f markdown
bash
# Use AI hybrid mode for complex tables
opendataloader-pdf input.pdf -o output/ -f markdown --hybrid docling-fast
# Extract only pages 1-5
opendataloader-pdf input.pdf -o output/ -f markdown --pages "1-5"
# Sanitize sensitive data
opendataloader-pdf input.pdf -o output/ -f json --sanitize
convert() call spawns a JVM process{output_name}_images/ directoryEnsure Java runtime is installed. The tool bundles its own PDFBox JAR.
Warnings about missing fonts are normal and don't affect output quality.
Use batch mode (multiple files in one call) instead of calling repeatedly.