Home
cd ../playbooks
File OrganizationAdvanced

Document Parser

Parse complex documents while preserving structure, tables, and figures using IBM's docling library.

10 minutes
By communitySource
#parsing#extraction#layout#docling

Your PDF has 200 pages with tables that span columns, figures with captions, and headers that break across pages. Copy-paste destroys the formatting. OCR misses half the tables. You need the structure, not just the text.

Who it's for: data engineers extracting structured data from PDFs, researchers parsing academic papers at scale, legal teams processing document archives, analysts converting reports into usable data, developers building document processing pipelines

Example

"Parse this 150-page financial report and extract all tables" → Structured output preserving every table with headers, multi-column layouts correctly merged, figures extracted with captions, and the full document hierarchy intact — ready for downstream analysis

CLAUDE.md Template

New here? 3-minute setup guide → | Already set up? Copy the template below.

Or install from your terminal:
npx ccplaybooks add doc-parser
# Document Parser

## Overview

This workflow enables advanced document parsing using **docling** - IBM's state-of-the-art document understanding library. Parse complex PDFs, Word documents, and images while preserving structure, extracting tables, figures, and handling multi-column layouts.

## How to Use

1. Provide the document to parse
2. Specify what you want to extract (text, tables, figures, etc.)
3. I'll parse it and return structured data

Get new playbooks like this one

One email a week with new Claude Code workflows. Free, like everything here.

No spam. Unsubscribe anytime.

README.md

What This Does

This workflow enables advanced document parsing using docling - IBM's state-of-the-art document understanding library. Parse complex PDFs, Word documents, and images while preserving structure, extracting tables, figures, and handling multi-column layouts.


Quick Start

Step 1: Create a Project Folder

mkdir -p ~/Documents/DocParser

Step 2: Download the Template

Click Download above, then:

mv ~/Downloads/CLAUDE.md ~/Documents/DocParser/

Step 3: Start Working

cd ~/Documents/DocParser
claude

How to Use

  1. Provide the document to parse
  2. Specify what you want to extract (text, tables, figures, etc.)
  3. I'll parse it and return structured data

Example prompts:

  • "Parse this PDF and extract all tables"
  • "Convert this academic paper to structured markdown"
  • "Extract figures and captions from this document"
  • "Parse this report preserving the document structure"

Best Practices

  1. Use Appropriate Pipeline: Configure for your document type
  2. Handle Large Documents: Process in chunks if needed
  3. Verify Table Extraction: Complex tables may need review
  4. Check OCR Quality: Enable OCR for scanned documents
  5. Cache Results: Store parsed documents for reuse

Examples

Example 1: Parse Financial Report

from docling.document_converter import DocumentConverter

def parse_financial_report(pdf_path):
    """Extract structured data from financial report."""
    
    converter = DocumentConverter()
    result = converter.convert(pdf_path)
    doc = result.document
    
    financial_data = {
        'income_statement': None,
        'balance_sheet': None,
        'cash_flow': None,
        'notes': []
    }
    
    # Extract tables
    tables = []
    for element in doc.iterate_items():
        if element.type == 'table':
            table_df = element.export_to_dataframe()
            
            # Identify table type
            if 'revenue' in str(table_df).lower() or 'income' in str(table_df).lower():
                financial_data['income_statement'] = table_df
            elif 'asset' in str(table_df).lower() or 'liabilities' in str(table_df).lower():
                financial_data['balance_sheet'] = table_df
            elif 'cash' in str(table_df).lower():
                financial_data['cash_flow'] = table_df
            else:
                tables.append(table_df)
    
    # Extract markdown for notes
    financial_data['markdown'] = doc.export_to_markdown()
    
    return financial_data

report = parse_financial_report('annual_report.pdf')
print("Income Statement:")
print(report['income_statement'])

Example 2: Technical Documentation Parser

from docling.document_converter import DocumentConverter

def parse_technical_docs(doc_path):
    """Parse technical documentation."""
    
    converter = DocumentConverter()
    result = converter.convert(doc_path)
    doc = result.document
    
    documentation = {
        'title': None,
        'version': None,
        'sections': [],
        'code_blocks': [],
        'diagrams': []
    }
    
    current_section = None
    
    for element in doc.iterate_items():
        if element.type == 'title':
            documentation['title'] = element.text
        
        elif element.type == 'heading':
            current_section = {
                'title': element.text,
                'level': element.level if hasattr(element, 'level') else 1,
                'content': []
            }
            documentation['sections'].append(current_section)
        
        elif element.type == 'code':
            if current_section:
                current_section['content'].append({
                    'type': 'code',
                    'content': element.text
                })
            documentation['code_blocks'].append(element.text)
        
        elif element.type == 'picture':
            documentation['diagrams'].append({
                'page': element.prov[0].page_no if element.prov else None,
                'caption': element.caption if hasattr(element, 'caption') else None
            })
    
    return documentation

docs = parse_technical_docs('api_documentation.pdf')
print(f"Title: {docs['title']}")
print(f"Sections: {len(docs['sections'])}")

Example 3: Contract Analysis

Limitations

  • Very large documents may require chunking
  • Handwritten content needs OCR preprocessing
  • Complex nested tables may need manual review
  • Some PDF types (encrypted) not supported
  • GPU recommended for best performance

Installation

pip install docling

# For full functionality
pip install docling[all]

# For OCR support
pip install docling[ocr]

$Related Playbooks

File Organization

Document Processing Pipeline

Chain document operations into reusable pipelines

10 minutes
Advanced
File Organization

7-Minute Digital Declutter

Complete digital cleanup of photos, documents, and downloads in 7 minutes with intelligent recommendations.

5 minutes
Beginner
File Organization

Word Document Manipulation

Create, edit, and manipulate Word documents programmatically using python-docx

10 minutes
Advanced
File Organization

CSV Data Visualizer

Create professional data visualizations, statistical reports, and interactive dashboards from CSV files for analysis and presentations.

5 minutes
Beginner
File Organization

Data Analyst Toolkit — CSV Analysis & Dashboard Generator

Analyze CSV and Excel data with automatic missing value detection, intelligent imputation, and interactive Plotly dashboards. Generate exploratory data analysis reports in minutes with Claude Code.

10 minutes
Intermediate
File Organization

Disk Space Analyzer

Find exactly what's eating your disk space with categorized breakdown and prioritized cleanup recommendations.

5 minutes
Beginner
File Organization

Duplicate File Detector

Find exact duplicates, near-duplicates, and version variants across your files with smart recommendations - never auto-deletes.

5 minutes
Beginner
File Organization

CSV & Excel Data Analyst

Ask questions about your spreadsheets in plain English. Get insights, summaries, and visualizations without knowing formulas or pivot tables.

5 minutes
Beginner
File Organization

Smart File Organizer

Organize and rename files based on content analysis

10 minutes
Advanced
File Organization

Natural Language Home Automation

Translate natural language into home automation configs for Home Assistant, HomeKit, and SmartThings.

10 minutes
Intermediate
File Organization

Intelligent File Organizer

Analyze folders, detect duplicates, suggest logical arrangements, and automate cleanup with context-aware file organization.

5 minutes
Beginner
File Organization

Document Layout Analyzer

Detect text blocks, tables, figures, and reading order in complex documents using surya.

10 minutes
Beginner

Browse all File Organization playbooks →