{"data":{"slug":"github-claude-office-skills-skills-pdf-to-docx-080b8fa8a8a4","title":"Convert PDF to Editable Word Document","summary":"Convert PDF files to editable Word documents using pdf2docx, preserving layout, tables, and formatting. The output is an editable Word document (.docx) that can be further edited.","url":"https:\/\/skillshunter.net\/skills\/github-claude-office-skills-skills-pdf-to-docx-080b8fa8a8a4","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-claude-office-skills-skills-pdf-to-docx-080b8fa8a8a4","markdown_url":"https:\/\/skillshunter.net\/skills\/github-claude-office-skills-skills-pdf-to-docx-080b8fa8a8a4.md","download_url":"https:\/\/skillshunter.net\/skills\/github-claude-office-skills-skills-pdf-to-docx-080b8fa8a8a4\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Scanned PDFs require OCR preprocessing before conversion. Ensure the PDF is not protected or encrypted, or provide a password if needed.","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: pdf-to-docx\ndescription: \"Convert PDF files to editable Word documents using pdf2docx\"\nversion: \"1.0\"\nauthor: claude-office-skills\nlicense: MIT\n\n# Categorization\ncategory: pdf\ntags:\n  - pdf\n  - docx\n  - conversion\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    - pdf_to_docx\n\n# Skill Capabilities\ncapabilities:\n  - format_conversion\n  - editable_documents\n\n# Language Support\nlanguages:\n  - en\n  - zh\n---\n\n# PDF to Word Skill\n\n## Overview\n\nThis skill enables conversion from PDF to editable Word documents using **pdf2docx** - a Python library that preserves layout, tables, images, and text formatting. Unlike OCR-based solutions, pdf2docx extracts native PDF content for accurate conversion.\n\n## How to Use\n\n1. Provide the PDF file you want to convert\n2. Optionally specify pages or conversion options\n3. I'll convert it to an editable Word document\n\n**Example prompts:**\n- \"Convert this PDF report to an editable Word document\"\n- \"Turn pages 1-5 of this PDF into Word format\"\n- \"Extract this scanned document as editable text\"\n- \"Convert this PDF contract to Word for editing\"\n\n## Domain Knowledge\n\n### pdf2docx Fundamentals\n\n```python\nfrom pdf2docx import Converter\n\n# Basic conversion\ncv = Converter('input.pdf')\ncv.convert('output.docx')\ncv.close()\n\n# Or using context manager\nwith Converter('input.pdf') as cv:\n    cv.convert('output.docx')\n```\n\n### Conversion Options\n\n```python\nfrom pdf2docx import Converter\n\ncv = Converter('input.pdf')\n\n# Full document\ncv.convert('output.docx')\n\n# Specific pages (0-indexed)\ncv.convert('output.docx', start=0, end=5)\n\n# Single page\ncv.convert('output.docx', pages=[0])\n\n# Multiple specific pages\ncv.convert('output.docx', pages=[0, 2, 4])\n\ncv.close()\n```\n\n### Advanced Options\n\n```python\nfrom pdf2docx import Converter\n\ncv = Converter('input.pdf')\n\ncv.convert(\n    'output.docx',\n    start=0,                    # Start page (0-indexed)\n    end=None,                   # End page (None = last page)\n    pages=None,                 # Specific pages list\n    password=None,              # PDF password if encrypted\n    min_section_height=20.0,    # Minimum height for section\n    connected_border_tolerance=0.5,  # Border detection tolerance\n    line_overlap_threshold=0.9, # Line merging threshold\n    line_break_width_ratio=0.5, # Line break detection\n    line_break_free_space_ratio=0.1,\n    line_separate_threshold=5,  # Vertical line separation\n    new_paragraph_free_space_ratio=0.85,\n    float_image_ignorable_gap=5,\n    page_margin_factor_top=0.5,\n    page_margin_factor_bottom=0.5,\n)\n\ncv.close()\n```\n\n### Handling Different PDF Types\n\n#### Native PDFs (Text-based)\n```python\n# Works best with native PDFs\ncv = Converter('native_pdf.pdf')\ncv.convert('output.docx')\ncv.close()\n```\n\n#### Scanned PDFs (Image-based)\n```python\n# For scanned PDFs, use OCR first\n# pdf2docx works best with native text PDFs\n# Consider using pytesseract or PaddleOCR first\n\nimport pytesseract\nfrom pdf2image import convert_from_path\n\n# Convert PDF pages to images\nimages = convert_from_path('scanned.pdf')\n\n# OCR each page\ntext = ''\nfor img in images:\n    text += pytesseract.image_to_string(img)\n\n# Then create Word document from text\n```\n\n### Python Integration\n\n```python\nfrom pdf2docx import Converter\nimport os\n\ndef pdf_to_word(pdf_path, output_path=None, pages=None):\n    \"\"\"Convert PDF to Word document.\"\"\"\n    if output_path is None:\n        output_path = pdf_path.replace('.pdf', '.docx')\n    \n    cv = Converter(pdf_path)\n    \n    if pages:\n        cv.convert(output_path, pages=pages)\n    else:\n        cv.convert(output_path)\n    \n    cv.close()\n    \n    return output_path\n\n# Usage\nresult = pdf_to_word('document.pdf')\nprint(f\"Created: {result}\")\n```\n\n### Batch Conversion\n\n```python\nfrom pdf2docx import Converter\nfrom pathlib import Path\nfrom concurrent.futures import ThreadPoolExecutor\n\ndef convert_single(pdf_path, output_dir):\n    \"\"\"Convert single PDF to Word.\"\"\"\n    output_path = output_dir \/ pdf_path.with_suffix('.docx').name\n    \n    try:\n        cv = Converter(str(pdf_path))\n        cv.convert(str(output_path))\n        cv.close()\n        return f\"Success: {pdf_path.name}\"\n    except Exception as e:\n        return f\"Error: {pdf_path.name} - {e}\"\n\ndef batch_convert(input_dir, output_dir, max_workers=4):\n    \"\"\"Convert all PDFs in directory.\"\"\"\n    input_path = Path(input_dir)\n    output_path = Path(output_dir)\n    output_path.mkdir(exist_ok=True)\n    \n    pdf_files = list(input_path.glob('*.pdf'))\n    \n    with ThreadPoolExecutor(max_workers=max_workers) as executor:\n        futures = [\n            executor.submit(convert_single, pdf, output_path)\n            for pdf in pdf_files\n        ]\n        \n        for future in futures:\n            print(future.result())\n\nbatch_convert('.\/pdfs', '.\/word_docs')\n```\n\n### Parsing PDF Structure\n\n```python\nfrom pdf2docx import Converter\n\ndef analyze_pdf(pdf_path):\n    \"\"\"Analyze PDF structure before conversion.\"\"\"\n    cv = Converter(pdf_path)\n    \n    for i, page in enumerate(cv.pages):\n        print(f\"Page {i+1}:\")\n        print(f\"  Size: {page.width} x {page.height}\")\n        print(f\"  Blocks: {len(page.blocks)}\")\n        \n        for block in page.blocks:\n            if hasattr(block, 'text'):\n                print(f\"    Text block: {block.text[:50]}...\")\n            elif hasattr(block, 'image'):\n                print(f\"    Image block\")\n    \n    cv.close()\n\nanalyze_pdf('document.pdf')\n```\n\n## Best Practices\n\n1. **Check PDF Type**: Native PDFs convert better than scanned\n2. **Preview First**: Test with a few pages before full conversion\n3. **Handle Tables**: Complex tables may need manual adjustment\n4. **Image Quality**: Images are extracted at original resolution\n5. **Font Handling**: Some fonts may substitute to system defaults\n\n## Common Patterns\n\n### Convert with Progress\n```python\nfrom pdf2docx import Converter\n\ndef convert_with_progress(pdf_path, output_path):\n    \"\"\"Convert PDF with progress tracking.\"\"\"\n    cv = Converter(pdf_path)\n    \n    total_pages = len(cv.pages)\n    print(f\"Converting {total_pages} pages...\")\n    \n    for i in range(total_pages):\n        cv.convert(output_path, start=i, end=i+1)\n        progress = (i + 1) \/ total_pages * 100\n        print(f\"Progress: {progress:.1f}%\")\n    \n    cv.close()\n    print(\"Conversion complete!\")\n```\n\n### Extract Tables Only\n```python\nfrom pdf2docx import Converter\nfrom docx import Document\n\ndef extract_tables_to_word(pdf_path, output_path):\n    \"\"\"Extract only tables from PDF to Word.\"\"\"\n    cv = Converter(pdf_path)\n    \n    # First do full conversion\n    temp_path = 'temp_full.docx'\n    cv.convert(temp_path)\n    cv.close()\n    \n    # Open and extract tables\n    doc = Document(temp_path)\n    new_doc = Document()\n    \n    for table in doc.tables:\n        # Copy table to new document\n        new_table = new_doc.add_table(rows=0, cols=len(table.columns))\n        \n        for row in table.rows:\n            new_row = new_table.add_row()\n            for i, cell in enumerate(row.cells):\n                new_row.cells[i].text = cell.text\n        \n        new_doc.add_paragraph()  # Add spacing\n    \n    new_doc.save(output_path)\n    os.remove(temp_path)\n```\n\n## Examples\n\n### Example 1: Contract Conversion\n```python\nfrom pdf2docx import Converter\nimport os\n\ndef convert_contract(pdf_path):\n    \"\"\"Convert contract PDF to editable Word with metadata.\"\"\"\n    \n    # Define output path\n    base_name = os.path.splitext(pdf_path)[0]\n    output_path = f\"{base_name}_editable.docx\"\n    \n    # Convert\n    cv = Converter(pdf_path)\n    \n    # Check page count\n    page_count = len(cv.pages)\n    print(f\"Processing {page_count} pages...\")\n    \n    # Convert all pages\n    cv.convert(output_path)\n    cv.close()\n    \n    print(f\"Created: {output_path}\")\n    print(f\"File size: {os.path.getsize(output_path) \/ 1024:.1f} KB\")\n    \n    return output_path\n\n# Usage\nresult = convert_contract('contract.pdf')\n```\n\n### Example 2: Selective Page Conversion\n```python\nfrom pdf2docx import Converter\n\ndef convert_selected_pages(pdf_path, page_ranges, output_path):\n    \"\"\"Convert specific page ranges to Word.\n    \n    page_ranges: List of tuples like [(1, 3), (5, 7)] for pages 1-3 and 5-7\n    \"\"\"\n    cv = Converter(pdf_path)\n    \n    # Convert pages (0-indexed internally)\n    all_pages = []\n    for start, end in page_ranges:\n        all_pages.extend(range(start - 1, end))  # Convert to 0-indexed\n    \n    cv.convert(output_path, pages=all_pages)\n    cv.close()\n    \n    print(f\"Converted pages: {page_ranges}\")\n    return output_path\n\n# Convert pages 1-5 and 10-15\nconvert_selected_pages(\n    'long_document.pdf',\n    [(1, 5), (10, 15)],\n    'selected_pages.docx'\n)\n```\n\n### Example 3: PDF Report to Editable Template\n```python\nfrom pdf2docx import Converter\nfrom docx import Document\n\ndef pdf_to_template(pdf_path, output_path):\n    \"\"\"Convert PDF report to Word template with placeholders.\"\"\"\n    \n    # Convert PDF to Word\n    cv = Converter(pdf_path)\n    cv.convert(output_path)\n    cv.close()\n    \n    # Open and add placeholder fields\n    doc = Document(output_path)\n    \n    # Replace common fields with placeholders\n    replacements = {\n        'Company Name': '[COMPANY_NAME]',\n        'Date:': 'Date: [DATE]',\n        'Prepared by:': 'Prepared by: [AUTHOR]',\n    }\n    \n    for para in doc.paragraphs:\n        for old, new in replacements.items():\n            if old in para.text:\n                para.text = para.text.replace(old, new)\n    \n    # Also check tables\n    for table in doc.tables:\n        for row in table.rows:\n            for cell in row.cells:\n                for old, new in replacements.items():\n                    if old in cell.text:\n                        cell.text = cell.text.replace(old, new)\n    \n    doc.save(output_path)\n    print(f\"Template created: {output_path}\")\n\npdf_to_template('annual_report.pdf', 'report_template.docx')\n```\n\n### Example 4: Bulk Invoice Processing\n```python\nfrom pdf2docx import Converter\nfrom pathlib import Path\nimport json\n\ndef process_invoices(input_folder, output_folder):\n    \"\"\"Convert PDF invoices to editable Word documents.\"\"\"\n    \n    input_path = Path(input_folder)\n    output_path = Path(output_folder)\n    output_path.mkdir(exist_ok=True)\n    \n    results = []\n    \n    for pdf_file in input_path.glob('*.pdf'):\n        output_file = output_path \/ pdf_file.with_suffix('.docx').name\n        \n        try:\n            cv = Converter(str(pdf_file))\n            cv.convert(str(output_file))\n            cv.close()\n            \n            results.append({\n                'file': pdf_file.name,\n                'status': 'success',\n                'output': str(output_file)\n            })\n            \n        except Exception as e:\n            results.append({\n                'file': pdf_file.name,\n                'status': 'error',\n                'error': str(e)\n            })\n    \n    # Save results log\n    with open(output_path \/ 'conversion_log.json', 'w') as f:\n        json.dump(results, f, indent=2)\n    \n    # Summary\n    success = sum(1 for r in results if r['status'] == 'success')\n    print(f\"Converted {success}\/{len(results)} files\")\n    \n    return results\n\nresults = process_invoices('.\/invoices_pdf', '.\/invoices_word')\n```\n\n## Limitations\n\n- Scanned PDFs require OCR preprocessing\n- Complex layouts may not convert perfectly\n- Some fonts may not be available\n- Watermarks are included in conversion\n- Protected\/encrypted PDFs need password\n\n## Installation\n\n```bash\npip install pdf2docx\n\n# For image handling\npip install Pillow\n```\n\n## Resources\n\n- [GitHub Repository](https:\/\/github.com\/dothinking\/pdf2docx)\n- [Documentation](https:\/\/pdf2docx.readthedocs.io\/)\n- [PyPI Package](https:\/\/pypi.org\/project\/pdf2docx\/)\n","use_cases":["Convert a PDF report to an editable Word document for further editing.","Turn specific pages of a PDF into Word format for review.","Extract text from a scanned PDF and convert it to an editable Word document."],"limitations":[],"compatibility":[],"setup_tip":"```bash\npip install pdf2docx\n\n# For image handling\npip install Pillow\n```","sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/claude-office-skills\/skills\/blob\/9c4c7d5cd2813a8936bf2c9fdb174ea883b85a11\/pdf-to-docx\/SKILL.md","source_commit":"9c4c7d5cd2813a8936bf2c9fdb174ea883b85a11","license":"MIT","version":null,"listing_approved_at":"2026-11-22","created_at":"2026-11-21T14:49:29.000000Z","updated_at":"2026-11-22T11:18:09.000000Z","seo_title":"Convert PDF to Word - Editable Document Conversion","seo_description":"Convert PDF files to editable Word documents with layout and formatting preserved. Use pdf2docx for accurate conversion.","seo_keywords":["convert pdf to word","pdf to docx conversion","editable document conversion","pdf to word online","pdf to editable word"]}}