{"data":{"slug":"github-claude-office-skills-skills-doc-parser-2a43e42a5fe3","title":"Extract Tables from PDF Documents","summary":"Extract structured tables from PDF documents using docling, preserving layout and data integrity. The output includes tables as dataframes with page numbers.","url":"https:\/\/skillshunter.net\/skills\/github-claude-office-skills-skills-doc-parser-2a43e42a5fe3","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-claude-office-skills-skills-doc-parser-2a43e42a5fe3","markdown_url":"https:\/\/skillshunter.net\/skills\/github-claude-office-skills-skills-doc-parser-2a43e42a5fe3.md","download_url":"https:\/\/skillshunter.net\/skills\/github-claude-office-skills-skills-doc-parser-2a43e42a5fe3\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"Install the docling library using pip before running the extraction commands. For best performance, use a GPU. Handwritten content requires OCR preprocessing, and encrypted PDFs are not supported.","instructions":"---\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n# CLAUDE OFFICE SKILL - Enhanced Metadata v2.0\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\n# Basic Information\nname: doc-parser\ndescription: \">\"\nversion: \"1.0\"\nauthor: claude-office-skills\nlicense: MIT\n\n# Categorization\ncategory: parsing\ntags:\n  - parsing\n  - extraction\n  - layout\n  - docling\ndepartment: All\n\n# AI Model Compatibility\nmodels:\n  recommended:\n    - claude-sonnet-4\n    - claude-opus-4\n  compatible:\n    - claude-3-5-sonnet\n    - gpt-4\n    - gpt-4o\n\n# MCP Tools Integration\nmcp:\n  server: office-mcp\n  tools:\n    - analyze_document_structure\n    - extract_text_from_pdf\n\n# Skill Capabilities\ncapabilities:\n  - document_parsing\n  - layout_analysis\n\n# Language Support\nlanguages:\n  - en\n  - zh\n---\n\n# Document Parser Skill\n\n## Overview\n\nThis skill 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.\n\n## How to Use\n\n1. Provide the document to parse\n2. Specify what you want to extract (text, tables, figures, etc.)\n3. I'll parse it and return structured data\n\n**Example prompts:**\n- \"Parse this PDF and extract all tables\"\n- \"Convert this academic paper to structured markdown\"\n- \"Extract figures and captions from this document\"\n- \"Parse this report preserving the document structure\"\n\n## Domain Knowledge\n\n### docling Fundamentals\n\n```python\nfrom docling.document_converter import DocumentConverter\n\n# Initialize converter\nconverter = DocumentConverter()\n\n# Convert document\nresult = converter.convert(\"document.pdf\")\n\n# Access parsed content\ndoc = result.document\nprint(doc.export_to_markdown())\n```\n\n### Supported Formats\n\n| Format | Extension | Notes |\n|--------|-----------|-------|\n| PDF | .pdf | Native and scanned |\n| Word | .docx | Full structure preserved |\n| PowerPoint | .pptx | Slides as sections |\n| Images | .png, .jpg | OCR + layout analysis |\n| HTML | .html | Structure preserved |\n\n### Basic Usage\n\n```python\nfrom docling.document_converter import DocumentConverter\n\n# Create converter\nconverter = DocumentConverter()\n\n# Convert single document\nresult = converter.convert(\"report.pdf\")\n\n# Access document\ndoc = result.document\n\n# Export options\nmarkdown = doc.export_to_markdown()\ntext = doc.export_to_text()\njson_doc = doc.export_to_dict()\n```\n\n### Advanced Configuration\n\n```python\nfrom docling.document_converter import DocumentConverter\nfrom docling.datamodel.base_models import InputFormat\nfrom docling.datamodel.pipeline_options import PdfPipelineOptions\n\n# Configure pipeline\npipeline_options = PdfPipelineOptions()\npipeline_options.do_ocr = True\npipeline_options.do_table_structure = True\npipeline_options.table_structure_options.do_cell_matching = True\n\n# Create converter with options\nconverter = DocumentConverter(\n    allowed_formats=[InputFormat.PDF, InputFormat.DOCX],\n    pdf_backend_options=pipeline_options\n)\n\nresult = converter.convert(\"document.pdf\")\n```\n\n### Document Structure\n\n```python\n# Document hierarchy\ndoc = result.document\n\n# Access metadata\nprint(doc.name)\nprint(doc.origin)\n\n# Iterate through content\nfor element in doc.iterate_items():\n    print(f\"Type: {element.type}\")\n    print(f\"Text: {element.text}\")\n    \n    if element.type == \"table\":\n        print(f\"Rows: {len(element.data.table_cells)}\")\n```\n\n### Extracting Tables\n\n```python\nfrom docling.document_converter import DocumentConverter\nimport pandas as pd\n\ndef extract_tables(doc_path):\n    \"\"\"Extract all tables from document.\"\"\"\n    converter = DocumentConverter()\n    result = converter.convert(doc_path)\n    doc = result.document\n    \n    tables = []\n    \n    for element in doc.iterate_items():\n        if element.type == \"table\":\n            # Get table data\n            table_data = element.export_to_dataframe()\n            tables.append({\n                'page': element.prov[0].page_no if element.prov else None,\n                'dataframe': table_data\n            })\n    \n    return tables\n\n# Usage\ntables = extract_tables(\"report.pdf\")\nfor i, table in enumerate(tables):\n    print(f\"Table {i+1} on page {table['page']}:\")\n    print(table['dataframe'])\n```\n\n### Extracting Figures\n\n```python\ndef extract_figures(doc_path, output_dir):\n    \"\"\"Extract figures with captions.\"\"\"\n    import os\n    \n    converter = DocumentConverter()\n    result = converter.convert(doc_path)\n    doc = result.document\n    \n    figures = []\n    os.makedirs(output_dir, exist_ok=True)\n    \n    for element in doc.iterate_items():\n        if element.type == \"picture\":\n            figure_info = {\n                'caption': element.caption if hasattr(element, 'caption') else None,\n                'page': element.prov[0].page_no if element.prov else None,\n            }\n            \n            # Save image if available\n            if hasattr(element, 'image'):\n                img_path = os.path.join(output_dir, f\"figure_{len(figures)+1}.png\")\n                element.image.save(img_path)\n                figure_info['path'] = img_path\n            \n            figures.append(figure_info)\n    \n    return figures\n```\n\n### Handling Multi-column Layouts\n\n```python\nfrom docling.document_converter import DocumentConverter\n\ndef parse_multicolumn(doc_path):\n    \"\"\"Parse document with multi-column layout.\"\"\"\n    \n    converter = DocumentConverter()\n    result = converter.convert(doc_path)\n    doc = result.document\n    \n    # docling automatically handles column detection\n    # Text is returned in reading order\n    \n    structured_content = []\n    \n    for element in doc.iterate_items():\n        content_item = {\n            'type': element.type,\n            'text': element.text if hasattr(element, 'text') else None,\n            'level': element.level if hasattr(element, 'level') else None,\n        }\n        \n        # Add bounding box if available\n        if element.prov:\n            content_item['bbox'] = element.prov[0].bbox\n            content_item['page'] = element.prov[0].page_no\n        \n        structured_content.append(content_item)\n    \n    return structured_content\n```\n\n### Export Formats\n\n```python\nfrom docling.document_converter import DocumentConverter\n\nconverter = DocumentConverter()\nresult = converter.convert(\"document.pdf\")\ndoc = result.document\n\n# Markdown export\nmarkdown = doc.export_to_markdown()\nwith open(\"output.md\", \"w\") as f:\n    f.write(markdown)\n\n# Plain text\ntext = doc.export_to_text()\n\n# JSON\/dict format\njson_doc = doc.export_to_dict()\n\n# HTML format (if supported)\n# html = doc.export_to_html()\n```\n\n### Batch Processing\n\n```python\nfrom docling.document_converter import DocumentConverter\nfrom pathlib import Path\nfrom concurrent.futures import ThreadPoolExecutor\n\ndef batch_parse(input_dir, output_dir, max_workers=4):\n    \"\"\"Parse multiple documents in parallel.\"\"\"\n    \n    input_path = Path(input_dir)\n    output_path = Path(output_dir)\n    output_path.mkdir(exist_ok=True)\n    \n    converter = DocumentConverter()\n    \n    def process_single(doc_path):\n        try:\n            result = converter.convert(str(doc_path))\n            md = result.document.export_to_markdown()\n            \n            out_file = output_path \/ f\"{doc_path.stem}.md\"\n            with open(out_file, 'w') as f:\n                f.write(md)\n            \n            return {'file': str(doc_path), 'status': 'success'}\n        except Exception as e:\n            return {'file': str(doc_path), 'status': 'error', 'error': str(e)}\n    \n    docs = list(input_path.glob('*.pdf')) + list(input_path.glob('*.docx'))\n    \n    with ThreadPoolExecutor(max_workers=max_workers) as executor:\n        results = list(executor.map(process_single, docs))\n    \n    return results\n```\n\n## Best Practices\n\n1. **Use Appropriate Pipeline**: Configure for your document type\n2. **Handle Large Documents**: Process in chunks if needed\n3. **Verify Table Extraction**: Complex tables may need review\n4. **Check OCR Quality**: Enable OCR for scanned documents\n5. **Cache Results**: Store parsed documents for reuse\n\n## Common Patterns\n\n### Academic Paper Parser\n```python\ndef parse_academic_paper(pdf_path):\n    \"\"\"Parse academic paper structure.\"\"\"\n    \n    converter = DocumentConverter()\n    result = converter.convert(pdf_path)\n    doc = result.document\n    \n    paper = {\n        'title': None,\n        'abstract': None,\n        'sections': [],\n        'references': [],\n        'tables': [],\n        'figures': []\n    }\n    \n    current_section = None\n    \n    for element in doc.iterate_items():\n        text = element.text if hasattr(element, 'text') else ''\n        \n        if element.type == 'title':\n            paper['title'] = text\n        \n        elif element.type == 'heading':\n            if 'abstract' in text.lower():\n                current_section = 'abstract'\n            elif 'reference' in text.lower():\n                current_section = 'references'\n            else:\n                paper['sections'].append({\n                    'title': text,\n                    'content': ''\n                })\n                current_section = 'section'\n        \n        elif element.type == 'paragraph':\n            if current_section == 'abstract':\n                paper['abstract'] = text\n            elif current_section == 'section' and paper['sections']:\n                paper['sections'][-1]['content'] += text + '\\n'\n        \n        elif element.type == 'table':\n            paper['tables'].append({\n                'caption': element.caption if hasattr(element, 'caption') else None,\n                'data': element.export_to_dataframe() if hasattr(element, 'export_to_dataframe') else None\n            })\n    \n    return paper\n```\n\n### Report to Structured Data\n```python\ndef parse_business_report(doc_path):\n    \"\"\"Parse business report into structured format.\"\"\"\n    \n    converter = DocumentConverter()\n    result = converter.convert(doc_path)\n    doc = result.document\n    \n    report = {\n        'metadata': {\n            'title': None,\n            'date': None,\n            'author': None\n        },\n        'executive_summary': None,\n        'sections': [],\n        'key_metrics': [],\n        'recommendations': []\n    }\n    \n    # Parse document structure\n    for element in doc.iterate_items():\n        # Implement parsing logic based on document structure\n        pass\n    \n    return report\n```\n\n## Examples\n\n### Example 1: Parse Financial Report\n```python\nfrom docling.document_converter import DocumentConverter\n\ndef parse_financial_report(pdf_path):\n    \"\"\"Extract structured data from financial report.\"\"\"\n    \n    converter = DocumentConverter()\n    result = converter.convert(pdf_path)\n    doc = result.document\n    \n    financial_data = {\n        'income_statement': None,\n        'balance_sheet': None,\n        'cash_flow': None,\n        'notes': []\n    }\n    \n    # Extract tables\n    tables = []\n    for element in doc.iterate_items():\n        if element.type == 'table':\n            table_df = element.export_to_dataframe()\n            \n            # Identify table type\n            if 'revenue' in str(table_df).lower() or 'income' in str(table_df).lower():\n                financial_data['income_statement'] = table_df\n            elif 'asset' in str(table_df).lower() or 'liabilities' in str(table_df).lower():\n                financial_data['balance_sheet'] = table_df\n            elif 'cash' in str(table_df).lower():\n                financial_data['cash_flow'] = table_df\n            else:\n                tables.append(table_df)\n    \n    # Extract markdown for notes\n    financial_data['markdown'] = doc.export_to_markdown()\n    \n    return financial_data\n\nreport = parse_financial_report('annual_report.pdf')\nprint(\"Income Statement:\")\nprint(report['income_statement'])\n```\n\n### Example 2: Technical Documentation Parser\n```python\nfrom docling.document_converter import DocumentConverter\n\ndef parse_technical_docs(doc_path):\n    \"\"\"Parse technical documentation.\"\"\"\n    \n    converter = DocumentConverter()\n    result = converter.convert(doc_path)\n    doc = result.document\n    \n    documentation = {\n        'title': None,\n        'version': None,\n        'sections': [],\n        'code_blocks': [],\n        'diagrams': []\n    }\n    \n    current_section = None\n    \n    for element in doc.iterate_items():\n        if element.type == 'title':\n            documentation['title'] = element.text\n        \n        elif element.type == 'heading':\n            current_section = {\n                'title': element.text,\n                'level': element.level if hasattr(element, 'level') else 1,\n                'content': []\n            }\n            documentation['sections'].append(current_section)\n        \n        elif element.type == 'code':\n            if current_section:\n                current_section['content'].append({\n                    'type': 'code',\n                    'content': element.text\n                })\n            documentation['code_blocks'].append(element.text)\n        \n        elif element.type == 'picture':\n            documentation['diagrams'].append({\n                'page': element.prov[0].page_no if element.prov else None,\n                'caption': element.caption if hasattr(element, 'caption') else None\n            })\n    \n    return documentation\n\ndocs = parse_technical_docs('api_documentation.pdf')\nprint(f\"Title: {docs['title']}\")\nprint(f\"Sections: {len(docs['sections'])}\")\n```\n\n### Example 3: Contract Analysis\n```python\nfrom docling.document_converter import DocumentConverter\n\ndef analyze_contract(pdf_path):\n    \"\"\"Parse contract document for key clauses.\"\"\"\n    \n    converter = DocumentConverter()\n    result = converter.convert(pdf_path)\n    doc = result.document\n    \n    contract = {\n        'parties': [],\n        'clauses': [],\n        'dates': [],\n        'amounts': [],\n        'full_text': doc.export_to_text()\n    }\n    \n    import re\n    \n    # Extract dates\n    date_pattern = r'\\b\\d{1,2}[\/-]\\d{1,2}[\/-]\\d{2,4}\\b|\\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]* \\d{1,2},? \\d{4}\\b'\n    contract['dates'] = re.findall(date_pattern, contract['full_text'], re.IGNORECASE)\n    \n    # Extract monetary amounts\n    amount_pattern = r'\\$[\\d,]+(?:\\.\\d{2})?|\\b\\d+(?:,\\d{3})*(?:\\.\\d{2})?\\s*(?:USD|dollars)\\b'\n    contract['amounts'] = re.findall(amount_pattern, contract['full_text'], re.IGNORECASE)\n    \n    # Parse sections as clauses\n    for element in doc.iterate_items():\n        if element.type == 'heading':\n            contract['clauses'].append({\n                'title': element.text,\n                'content': ''\n            })\n        elif element.type == 'paragraph' and contract['clauses']:\n            contract['clauses'][-1]['content'] += element.text + '\\n'\n    \n    return contract\n\ncontract_data = analyze_contract('agreement.pdf')\nprint(f\"Key dates: {contract_data['dates']}\")\nprint(f\"Amounts: {contract_data['amounts']}\")\n```\n\n## Limitations\n\n- Very large documents may require chunking\n- Handwritten content needs OCR preprocessing\n- Complex nested tables may need manual review\n- Some PDF types (encrypted) not supported\n- GPU recommended for best performance\n\n## Installation\n\n```bash\npip install docling\n\n# For full functionality\npip install docling[all]\n\n# For OCR support\npip install docling[ocr]\n```\n\n## Resources\n\n- [docling GitHub](https:\/\/github.com\/DS4SD\/docling)\n- [Documentation](https:\/\/ds4sd.github.io\/docling\/)\n- [IBM Research Blog](https:\/\/research.ibm.com\/)\n","use_cases":["Extract all tables from an academic research paper","Parse financial reports to extract key metrics","Convert multi-page PDFs to structured markdown tables"],"limitations":[],"compatibility":[],"setup_tip":"```bash\npip install docling\n\n# For full functionality\npip install docling[all]\n\n# For OCR support\npip install docling[ocr]\n```","sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/claude-office-skills\/skills\/blob\/9c4c7d5cd2813a8936bf2c9fdb174ea883b85a11\/doc-parser\/SKILL.md","source_commit":"9c4c7d5cd2813a8936bf2c9fdb174ea883b85a11","license":"MIT","version":null,"listing_approved_at":"2026-11-22","created_at":"2026-11-21T13:32:24.000000Z","updated_at":"2026-11-22T11:17:55.000000Z","seo_title":"Extract Tables from PDF Documents","seo_description":"Extract tables from PDF documents with structured data and layout preservation using docling.","seo_keywords":["extract tables from PDF","parse PDF tables","document table extraction","PDF table parser","structured table extraction"]}}