π Doctra - Document Parser Library ππ

π Table of Contents
π οΈ Installation
From PyPI (recommended)
pip install doctra
From source
git clone https://github.com/AdemBoukhris457/Doctra.git
cd Doctra
pip install .
System Dependencies
Doctra requires Poppler for PDF processing. Install it based on your operating system:
Ubuntu/Debian
sudo apt install poppler-utils
macOS
brew install poppler
Windows
Download and install from Poppler for Windows or use conda:
conda install -c conda-forge poppler
Google Colab
!sudo apt install poppler-utils
β‘ Quick Start
from doctra.parsers.structured_pdf_parser import StructuredPDFParser
parser = StructuredPDFParser()
parser.parse("path/to/your/document.pdf")
π§ Core Components
StructuredPDFParser
The StructuredPDFParser is a comprehensive PDF parser that extracts all types of content from PDF documents. It processes PDFs through layout detection, extracts text using OCR, saves images for visual elements, and optionally converts charts/tables to structured data using Vision Language Models (VLM).
Key Features:
- Layout Detection: Uses PaddleOCR for accurate document layout analysis
- OCR Processing: Supports both PyTesseract (default) and PaddleOCR PP-OCRv5_server for text extraction
- Visual Element Extraction: Saves figures, charts, and tables as images
- VLM Integration: Optional conversion of visual elements to structured data
- Multiple Output Formats: Generates Markdown, Excel, and structured JSON
Basic Usage:
from doctra.parsers.structured_pdf_parser import StructuredPDFParser
parser = StructuredPDFParser()
from doctra.engines.vlm.service import VLMStructuredExtractor
vlm_engine = VLMStructuredExtractor(
vlm_provider="openai",
api_key="your_api_key_here"
)
parser = StructuredPDFParser(vlm=vlm_engine)
parser.parse("document.pdf")
OCR Engine Configuration:
Doctra uses a dependency injection pattern for OCR engines. You initialize the OCR engine externally and pass it to the parser:
from doctra.parsers.structured_pdf_parser import StructuredPDFParser
from doctra.engines.ocr import PytesseractOCREngine, PaddleOCREngine
parser = StructuredPDFParser()
tesseract_ocr = PytesseractOCREngine(
lang="eng",
psm=4,
oem=3,
extra_config=""
)
parser = StructuredPDFParser(ocr_engine=tesseract_ocr)
paddle_ocr = PaddleOCREngine(
device="gpu",
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False
)
parser = StructuredPDFParser(ocr_engine=paddle_ocr)
shared_ocr = PytesseractOCREngine(lang="eng", psm=6, oem=3)
parser1 = StructuredPDFParser(ocr_engine=shared_ocr)
parser2 = EnhancedPDFParser(ocr_engine=shared_ocr)
VLM Engine Configuration:
Doctra uses the same dependency injection pattern for VLM engines. You initialize the VLM engine externally and pass it to the parser:
from doctra.parsers.structured_pdf_parser import StructuredPDFParser
from doctra.engines.vlm.service import VLMStructuredExtractor
parser = StructuredPDFParser()
vlm_engine = VLMStructuredExtractor(
vlm_provider="openai",
vlm_model="gpt-5",
api_key="your_api_key"
)
parser = StructuredPDFParser(vlm=vlm_engine)
shared_vlm = VLMStructuredExtractor(
vlm_provider="gemini",
api_key="your_api_key"
)
parser1 = StructuredPDFParser(vlm=shared_vlm)
parser2 = EnhancedPDFParser(vlm=shared_vlm)
parser3 = ChartTablePDFParser(vlm=shared_vlm)
Advanced Configuration:
from doctra.engines.ocr import PytesseractOCREngine, PaddleOCREngine
ocr_engine = PytesseractOCREngine(
lang="eng",
psm=4,
oem=3,
extra_config=""
)
from doctra.engines.vlm.service import VLMStructuredExtractor
vlm_engine = VLMStructuredExtractor(
vlm_provider="openai",
vlm_model="gpt-5",
api_key="your_api_key"
)
parser = StructuredPDFParser(
vlm=vlm_engine,
layout_model_name="PP-DocLayout_plus-L",
dpi=200,
min_score=0.0,
ocr_engine=ocr_engine,
box_separator="\n"
)
paddle_ocr = PaddleOCREngine(
device="gpu",
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False
)
parser = StructuredPDFParser(
ocr_engine=paddle_ocr,
)
EnhancedPDFParser
The EnhancedPDFParser extends the StructuredPDFParser with advanced image restoration capabilities using DocRes. This parser is ideal for processing scanned documents, low-quality PDFs, or documents with visual distortions that need enhancement before parsing.
Key Features:
- Image Restoration: Uses DocRes for document enhancement before processing
- Multiple Restoration Tasks: Supports dewarping, deshadowing, appearance enhancement, deblurring, binarization, and end-to-end restoration
- Enhanced Quality: Improves document quality for better OCR and layout detection
- All StructuredPDFParser Features: Inherits all capabilities of the base parser
- Flexible Configuration: Extensive options for restoration and processing
Basic Usage:
from doctra.parsers.enhanced_pdf_parser import EnhancedPDFParser
parser = EnhancedPDFParser(
use_image_restoration=True,
restoration_task="appearance"
)
parser.parse("scanned_document.pdf")
Advanced Configuration:
from doctra.engines.ocr import PytesseractOCREngine, PaddleOCREngine
ocr_engine = PytesseractOCREngine(
lang="eng",
psm=6,
oem=3
)
from doctra.engines.vlm.service import VLMStructuredExtractor
vlm_engine = VLMStructuredExtractor(
vlm_provider="openai",
vlm_model="gpt-4-vision",
api_key="your_api_key"
)
parser = EnhancedPDFParser(
use_image_restoration=True,
restoration_task="dewarping",
restoration_device="cuda",
restoration_dpi=300,
vlm=vlm_engine,
layout_model_name="PP-DocLayout_plus-L",
dpi=200,
min_score=0.5,
ocr_engine=ocr_engine,
)
DocRes Restoration Tasks:
appearance | General appearance enhancement | Most documents (default) |
dewarping | Correct perspective distortion | Scanned documents with perspective issues |
deshadowing | Remove shadows and lighting artifacts | Documents with shadow problems |
deblurring | Reduce blur and improve sharpness | Blurry or low-quality scans |
binarization | Convert to black and white | Documents needing clean binarization |
end2end | Complete restoration pipeline | Severely degraded documents |
ChartTablePDFParser
The ChartTablePDFParser is a specialized parser focused specifically on extracting charts and tables from PDF documents. It's optimized for scenarios where you only need these specific elements, providing faster processing and more targeted output.
Key Features:
- Focused Extraction: Extracts only charts and/or tables
- Selective Processing: Choose to extract charts, tables, or both
- VLM Integration: Optional conversion to structured data
- Organized Output: Separate directories for charts and tables
- Progress Tracking: Real-time progress bars for extraction
Basic Usage:
from doctra.parsers.table_chart_extractor import ChartTablePDFParser
parser = ChartTablePDFParser(
extract_charts=True,
extract_tables=True
)
parser = ChartTablePDFParser(
extract_charts=True,
extract_tables=False
)
parser.parse("document.pdf", output_base_dir="my_outputs")
Advanced Configuration:
from doctra.engines.vlm.service import VLMStructuredExtractor
vlm_engine = VLMStructuredExtractor(
vlm_provider="openai",
vlm_model="gpt-5",
api_key="your_api_key"
)
parser = ChartTablePDFParser(
extract_charts=True,
extract_tables=True,
vlm=vlm_engine,
layout_model_name="PP-DocLayout_plus-L",
dpi=200,
min_score=0.0
)
PaddleOCRVLPDFParser
The PaddleOCRVLPDFParser uses PaddleOCRVL (Vision-Language Model) for end-to-end document parsing. It combines PaddleOCRVL's advanced document understanding capabilities with DocRes image restoration and split table merging, providing a comprehensive solution for complex document processing.
Installation Requirements
Before using PaddleOCRVLPDFParser, install the required dependencies:
pip install -U "paddleocr[doc-parser]"
For Linux systems:
python -m pip install https://paddle-whl.bj.bcebos.com/nightly/cu126/safetensors/safetensors-0.6.2.dev0-cp38-abi3-linux_x86_64.whl
For Windows systems:
python -m pip install https://xly-devops.cdn.bcebos.com/safetensors-nightly/safetensors-0.6.2.dev0-cp38-abi3-win_amd64.whl
Key Features:
- End-to-End Parsing: Uses PaddleOCRVL for complete document understanding in a single pass
- Chart Recognition: Automatically extracts and converts charts to structured table format
- Document Restoration: Optional DocRes integration for enhanced document quality
- Split Table Merging: Automatically detects and merges tables split across pages
- Structured Output: Generates Markdown, HTML, and Excel files with tables and charts
- Multiple Element Types: Handles headers, text, tables, charts, footnotes, and more
Basic Usage:
from doctra import PaddleOCRVLPDFParser
parser = PaddleOCRVLPDFParser(
use_image_restoration=True,
use_chart_recognition=True,
merge_split_tables=True,
device="gpu"
)
parser.parse("document.pdf")
Advanced Configuration:
from doctra import PaddleOCRVLPDFParser
parser = PaddleOCRVLPDFParser(
use_image_restoration=True,
restoration_task="appearance",
restoration_device="cuda",
restoration_dpi=300,
use_chart_recognition=True,
use_doc_orientation_classify=True,
use_doc_unwarping=True,
use_layout_detection=True,
device="gpu",
merge_split_tables=True,
bottom_threshold_ratio=0.20,
top_threshold_ratio=0.15,
max_gap_ratio=0.25,
column_alignment_tolerance=10.0,
min_merge_confidence=0.65
)
parser.parse("document.pdf", output_dir="custom_output")
Output Structure:
The parser generates output in outputs/{document_name}/paddleocr_vl_parse/ with:
- result.md: Markdown file with all extracted content
- result.html: HTML file with formatted output
- tables.xlsx: Excel file containing all tables and charts as structured data
- tables.html: HTML file with structured tables and charts
- enhanced_pages/: Directory with DocRes-enhanced page images (if restoration enabled)
- tables/: Directory with merged table images (if split tables detected)
Example Output:
The parser extracts various document elements:
- Headers: Document titles and section headers
- Text: Paragraphs and body text
- Tables: Extracted as HTML and converted to Excel format
- Charts: Converted from visual format to structured table data
- Footnotes: Vision-based footnote detection
- Figure Titles: Captions and figure descriptions
StructuredDOCXParser
The StructuredDOCXParser is a comprehensive parser for Microsoft Word documents (.docx files) that extracts text, tables, images, and structured content while preserving document formatting and order. It supports VLM integration for enhanced content analysis and structured data extraction.
Key Features:
- Complete DOCX Support: Extracts text, tables, images, and formatting from Word documents
- Document Order Preservation: Maintains the original sequence of elements (paragraphs, tables, images)
- VLM Integration: Optional Vision Language Model support for image analysis and table extraction
- Multiple Output Formats: Generates Markdown, HTML, and Excel files
- Excel Export: Creates structured Excel files with Table of Contents and clickable hyperlinks
- Formatting Preservation: Maintains text formatting (bold, italic, etc.) in output
- Progress Tracking: Real-time progress bars for VLM processing
Basic Usage:
from doctra.parsers.structured_docx_parser import StructuredDOCXParser
parser = StructuredDOCXParser(
extract_images=True,
preserve_formatting=True,
table_detection=True,
export_excel=True
)
parser.parse("document.docx")
Advanced Configuration with VLM:
from doctra.engines.vlm.service import VLMStructuredExtractor
vlm_engine = VLMStructuredExtractor(
vlm_provider="openai",
vlm_model="gpt-4-vision",
api_key="your_api_key"
)
parser = StructuredDOCXParser(
vlm=vlm_engine,
extract_images=True,
preserve_formatting=True,
table_detection=True,
export_excel=True
)
parser.parse("document.docx")
Output Structure:
When parsing a DOCX document, the parser creates:
outputs/document_name/
βββ document.md # Markdown version with all content
βββ document.html # HTML version with styling
βββ tables.xlsx # Excel file with extracted tables
β βββ Table of Contents # Summary sheet with hyperlinks
β βββ Table 1 # Individual table sheets
β βββ Table 2
β βββ ...
βββ images/ # Extracted images
βββ image1.png
βββ image2.jpg
βββ ...
VLM Integration Features:
When VLM is enabled, the parser:
- Analyzes Images: Uses AI to extract structured data from images
- Creates Tables: Converts chart images to structured table data
- Enhanced Excel Output: Includes VLM-extracted tables in Excel file
- Smart Content Display: Shows extracted tables instead of images in Markdown/HTML
- Progress Tracking: Shows progress based on number of images processed
CLI Usage:
doctra parse-docx document.docx
doctra parse-docx document.docx --use-vlm --vlm-provider openai --vlm-api-key your_key
doctra parse-docx document.docx \
--extract-images \
--preserve-formatting \
--table-detection \
--export-excel
DocResEngine
The DocResEngine provides direct access to DocRes image restoration capabilities. This engine is perfect for standalone image restoration tasks or when you need fine-grained control over the restoration process.
Key Features:
- Direct Image Restoration: Process individual images or entire PDFs
- Multiple Restoration Tasks: All 6 DocRes restoration tasks available
- GPU Acceleration: Automatic CUDA detection and optimization
- Flexible Input/Output: Support for various image formats and PDFs
- Metadata Extraction: Get detailed information about restoration process
Basic Usage:
from doctra.engines.image_restoration import DocResEngine
docres = DocResEngine(device="cuda")
restored_img, metadata = docres.restore_image(
image="path/to/image.jpg",
task="appearance"
)
enhanced_pdf = docres.restore_pdf(
pdf_path="document.pdf",
output_path="enhanced_document.pdf",
task="appearance"
)
Advanced Usage:
docres = DocResEngine(
device="cuda",
use_half_precision=True,
model_path="custom/model.pth",
mbd_path="custom/mbd.pth"
)
images = ["doc1.jpg", "doc2.jpg", "doc3.jpg"]
for img_path in images:
restored_img, metadata = docres.restore_image(
image=img_path,
task="dewarping"
)
print(f"Processed {img_path}: {metadata}")
pdfs = ["report1.pdf", "report2.pdf"]
for pdf_path in pdfs:
output_path = f"enhanced_{os.path.basename(pdf_path)}"
docres.restore_pdf(
pdf_path=pdf_path,
output_path=output_path,
task="end2end"
)
Supported Restoration Tasks:
appearance | General appearance enhancement | Default choice for most documents |
dewarping | Correct document perspective distortion | Scanned documents with perspective issues |
deshadowing | Remove shadows and lighting artifacts | Documents with shadow problems |
deblurring | Reduce blur and improve sharpness | Blurry or low-quality scans |
binarization | Convert to black and white | Documents needing clean binarization |
end2end | Complete restoration pipeline | Severely degraded documents |
π₯οΈ Web UI (Gradio)
Doctra provides a comprehensive web interface built with Gradio that makes document processing accessible to non-technical users.
Features:
- Drag & Drop Interface: Upload PDFs by dragging and dropping
- Multiple Parsers: Choose between full parsing, enhanced parsing, and chart/table extraction
- Real-time Processing: See progress as documents are processed
- VLM Integration: Configure API keys for AI features
- Output Preview: View results directly in the browser
- Download Results: Download processed files as ZIP archives
Launch the Web UI:
from doctra.ui.app import launch_ui
launch_ui()
Or from command line:
python gradio_app.py
Web UI Components:
- Full Parse Tab: Complete document processing with page navigation
- DOCX Parser Tab: Microsoft Word document parsing with VLM integration
- Tables & Charts Tab: Specialized extraction with VLM integration
- DocRes Tab: Image restoration with before/after comparison
- Enhanced Parser Tab: Enhanced parsing with DocRes integration
Command Line Interface
Doctra includes a powerful CLI for batch processing and automation.
Available Commands:
doctra parse document.pdf
doctra parse-docx document.docx
doctra enhance document.pdf --restoration-task appearance
doctra extract charts document.pdf
doctra extract tables document.pdf
doctra extract both document.pdf --use-vlm
doctra visualize document.pdf
doctra analyze document.pdf
doctra info
CLI Examples:
doctra enhance document.pdf \
--restoration-task dewarping \
--restoration-device cuda \
--use-vlm \
--vlm-provider openai \
--vlm-api-key your_key
doctra extract charts document.pdf \
--use-vlm \
--vlm-provider gemini \
--vlm-api-key your_key
doctra parse *.pdf --output-dir results/
π¨ Visualization
Doctra provides powerful visualization capabilities to help you understand how the layout detection works and verify the accuracy of element extraction.
Layout Detection Visualization
The StructuredPDFParser includes a built-in visualization method that displays PDF pages with bounding boxes overlaid on detected elements. This is perfect for:
- Debugging: Verify that layout detection is working correctly
- Quality Assurance: Check the accuracy of element identification
- Documentation: Create visual documentation of extraction results
- Analysis: Understand document structure and layout patterns
Basic Visualization:
from doctra.parsers.structured_pdf_parser import StructuredPDFParser
parser = StructuredPDFParser()
parser.display_pages_with_boxes("document.pdf")
Advanced Visualization with Custom Settings:
parser.display_pages_with_boxes(
pdf_path="document.pdf",
num_pages=5,
cols=3,
page_width=600,
spacing=30,
save_path="layout_visualization.png"
)
Visualization Features:
- Color-coded Elements: Each element type (text, table, chart, figure) has a distinct color
- Confidence Scores: Shows detection confidence for each element
- Grid Layout: Multiple pages displayed in an organized grid
- Interactive Legend: Color legend showing all detected element types
- High Quality: High-resolution output suitable for documentation
- Flexible Output: Display on screen or save to file
Example Output:
The visualization shows:
- Blue boxes: Text elements
- Red boxes: Tables
- Green boxes: Charts
- Orange boxes: Figures
- Labels: Element type and confidence score (e.g., "table (0.95)")
- Page titles: Page number and element count
- Summary statistics: Total elements detected by type
Use Cases for Visualization:
- Document Analysis: Quickly assess document structure and complexity
- Quality Control: Verify extraction accuracy before processing
- Debugging: Identify issues with layout detection
- Documentation: Create visual reports of extraction results
- Training: Help users understand how the system works
Visualization Configuration Options:
num_pages | 3 | Number of pages to visualize |
cols | 2 | Number of columns in grid layout |
page_width | 800 | Width of each page in pixels |
spacing | 40 | Spacing between pages in pixels |
save_path | None | Path to save visualization (if None, displays on screen) |
π Interactive Notebooks
| 01_doctra_quick_start |  | Comprehensive tutorial covering layout detection, content extraction, and multi-format outputs with visual examples |
π Usage Examples
Example 1: Basic Document Processing
from doctra.parsers.structured_pdf_parser import StructuredPDFParser
parser = StructuredPDFParser()
parser.parse("financial_report.pdf")
Example 2: Enhanced Parsing with Image Restoration
from doctra.parsers.enhanced_pdf_parser import EnhancedPDFParser
from doctra.engines.ocr import PytesseractOCREngine
ocr_engine = PytesseractOCREngine(lang="eng", psm=4, oem=3)
from doctra.engines.vlm.service import VLMStructuredExtractor
vlm_engine = VLMStructuredExtractor(
vlm_provider="openai",
api_key="your_api_key"
)
parser = EnhancedPDFParser(
use_image_restoration=True,
restoration_task="dewarping",
restoration_device="cuda",
ocr_engine=ocr_engine,
vlm=vlm_engine
)
parser.parse("scanned_document.pdf")
Example 2b: Using PaddleOCR for Better Accuracy
from doctra.parsers.structured_pdf_parser import StructuredPDFParser
from doctra.engines.ocr import PaddleOCREngine
paddle_ocr = PaddleOCREngine(
device="gpu",
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False
)
parser = StructuredPDFParser(
ocr_engine=paddle_ocr
)
parser.parse("complex_document.pdf")
Example 3: Direct Image Restoration
from doctra.engines.image_restoration import DocResEngine
docres = DocResEngine(device="cuda")
restored_img, metadata = docres.restore_image(
image="blurry_document.jpg",
task="deblurring"
)
docres.restore_pdf(
pdf_path="low_quality.pdf",
output_path="enhanced.pdf",
task="appearance"
)
Example 4: DOCX Document Parsing
from doctra.parsers.structured_docx_parser import StructuredDOCXParser
parser = StructuredDOCXParser(
extract_images=True,
preserve_formatting=True,
table_detection=True,
export_excel=True
)
parser.parse("report.docx")
Example 5: DOCX Parsing with VLM Enhancement
from doctra.parsers.structured_docx_parser import StructuredDOCXParser
from doctra.engines.vlm.service import VLMStructuredExtractor
vlm_engine = VLMStructuredExtractor(
vlm_provider="openai",
vlm_model="gpt-4-vision",
api_key="your_api_key"
)
parser = StructuredDOCXParser(
vlm=vlm_engine,
extract_images=True,
preserve_formatting=True,
table_detection=True,
export_excel=True
)
parser.parse("financial_report.docx")
Example 6: PaddleOCRVL End-to-End Parsing
from doctra import PaddleOCRVLPDFParser
parser = PaddleOCRVLPDFParser(
use_image_restoration=True,
restoration_task="appearance",
use_chart_recognition=True,
merge_split_tables=True,
device="gpu"
)
parser.parse("financial_report.pdf")
Example 7: Chart and Table Extraction with VLM
from doctra.parsers.table_chart_extractor import ChartTablePDFParser
from doctra.engines.vlm.service import VLMStructuredExtractor
vlm_engine = VLMStructuredExtractor(
vlm_provider="openai",
api_key="your_api_key"
)
parser = ChartTablePDFParser(
extract_charts=True,
extract_tables=True,
vlm=vlm_engine
)
parser.parse("data_report.pdf", output_base_dir="extracted_data")
Example 8: Web UI Usage
from doctra.ui.app import launch_ui
launch_ui()
from doctra.ui.app import build_demo
demo = build_demo()
demo.launch(share=True)
Example 9: Command Line Usage
doctra parse-docx document.docx \
--use-vlm \
--vlm-provider openai \
--vlm-api-key your_key \
--extract-images \
--export-excel
doctra enhance document.pdf \
--restoration-task dewarping \
--restoration-device cuda \
--use-vlm \
--vlm-provider openai \
--vlm-api-key your_key
doctra extract charts document.pdf \
--use-vlm \
--vlm-provider gemini \
--vlm-api-key your_key
doctra parse *.pdf --output-dir results/
Example 10: Layout Visualization
from doctra.parsers.structured_pdf_parser import StructuredPDFParser
parser = StructuredPDFParser()
parser.display_pages_with_boxes(
pdf_path="research_paper.pdf",
num_pages=6,
cols=2,
page_width=700,
spacing=50,
save_path="research_paper_layout.png"
)
parser.display_pages_with_boxes("document.pdf")
β¨ Features
π Layout Detection
- Advanced document layout analysis using PaddleOCR
- Accurate identification of text, tables, charts, and figures
- Configurable confidence thresholds
π OCR Processing
- Dual OCR Engine Support: Choose between PyTesseract (default) or PaddleOCR PP-OCRv5_server
- Dependency Injection Pattern: Initialize OCR engines externally and pass them to parsers for clearer API
- PaddleOCR PP-OCRv5_server: Advanced model from PaddleOCR 3.0 with superior accuracy
- PyTesseract: Traditional OCR with extensive language support and fine-grained control
- Reusable Engines: Create OCR engine instances once and reuse across multiple parsers
- Support for multiple languages (PyTesseract)
- GPU acceleration for PaddleOCR
- Configurable OCR parameters for both engines
π§ PaddleOCRVL End-to-End Parsing
- Vision-Language Model: Advanced document understanding using PaddleOCRVL
- Complete Document Parsing: Single-pass extraction of all content types
- Chart Recognition: Automatic chart detection and conversion to structured tables
- Multi-Element Support: Handles headers, text, tables, charts, footnotes, and figure titles
- Integrated Restoration: Optional DocRes image restoration for enhanced quality
- Split Table Merging: Automatic detection and merging of tables across pages
- Structured Output: Generates Excel files with both tables and charts
- Automatic cropping and saving of figures, charts, and tables
- Organized output directory structure
- High-resolution image preservation
π§ Image Restoration (DocRes)
- 6 Restoration Tasks: Dewarping, deshadowing, appearance enhancement, deblurring, binarization, and end-to-end restoration
- GPU Acceleration: Automatic CUDA detection and optimization
- Enhanced Quality: Improves document quality for better OCR and layout detection
- Flexible Processing: Standalone image restoration or integrated with parsing
π€ VLM Integration
- Dependency Injection Pattern: Initialize VLM engines externally and pass them to parsers for clearer API
- Vision Language Model Support: Structured data extraction from visual elements
- Multiple Provider Options: OpenAI, Gemini, Anthropic, OpenRouter, Qianfan, Ollama
- Reusable Engines: Create VLM engine instances once and reuse across multiple parsers
- Automatic Conversion: Charts and tables converted to structured formats (Excel, HTML, JSON)
π Multiple Output Formats
- Markdown: Human-readable document with embedded images and tables
- Excel: Structured data in spreadsheet format
- JSON: Programmatically accessible structured data
- HTML: Interactive web-ready documents
- Images: High-quality cropped visual elements
π₯οΈ User Interfaces
- Web UI: Gradio-based interface with drag & drop functionality
- Command Line: Powerful CLI for batch processing and automation
- Multiple Tabs: Full parsing, DOCX parsing, enhanced parsing, chart/table extraction, and image restoration
βοΈ Flexible Configuration
- Extensive customization options
- Performance tuning parameters
- Output format selection
- Device selection (CPU/GPU)
π Acknowledgments
Doctra builds upon several excellent open-source projects:
- PaddleOCR - Advanced document layout detection and OCR capabilities
- DocRes - State-of-the-art document image restoration model
- Outlines - Structured output generation for LLMs
We thank the developers and contributors of these projects for their valuable work that makes Doctra possible.