[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6XBYDPDQKDW6F81CGDBJ8XA":3,"skill-same:01M6XBYDPDQKDW6F81CGDBJ8XA":64},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":22,"publishedAt":33,"linkOnly":34,"markdownContent":35,"markdownBody":36,"frontMatter":37,"refName":38,"commitSha":39,"skillDirectory":40,"forksCount":13,"repositoryHtmlUrl":41,"repositoryHomepageUrl":6,"ownerHtmlUrl":42,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":43,"install":44,"resources":57},"01M6XBYDPDQKDW6F81CGDBJ8XA","robust-pdf-extraction",null,"Multi-method PDF extraction with sequential fallback and OCR for scanned documents","UF-gzj\u002Fopenspace-claude-evolution","UF-gzj","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F272393507?v=4","01M6XBCZB755P01VVYGQWPYZY3","01M6XBCZFJA5AREA17WGETA3FW",0,"MIT","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Frobust-pdf-extraction\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000002","文档处理","SCENARIO","使用场景",[23,24,25,26,27,28,29,30,31,32],"PDF","extraction","pdf extraction","robust pdf extraction","documents","ocr","fallback","multi","with","for","2026-11-10 10:12:30",false,"---\nname: robust-pdf-extraction\ndescription: Multi-method PDF extraction with sequential fallback and OCR for scanned documents\n---\n\n# Robust PDF Extraction Workflow\n\nThis skill provides a systematic approach to extracting text from PDF files, handling both text-based and scanned\u002Fimage-based documents through progressive fallback methods.\n\n## When to Use\n\n- Processing PDFs of unknown or mixed types (text vs. scanned images)\n- Critical document processing where extraction failure is not acceptable\n- Batch processing multiple PDFs with varying formats\n\n## Workflow Steps\n\n### Step 1: Verify File Accessibility\n\nBefore attempting extraction, confirm the PDF exists and is readable:\n\n```bash\n# Check file exists and get basic info\nls -la \u002Fpath\u002Fto\u002Fdocument.pdf\n\n# Or search for files if location uncertain\nfind \u002Fpath -name \"*.pdf\" -type f 2>\u002Fdev\u002Fnull\n```\n\n### Step 2: Attempt Primary Extraction (pdfplumber)\n\nStart with pdfplumber for best text structure preservation:\n\n```python\nimport pdfplumber\n\ndef extract_with_pdfplumber(pdf_path):\n    text = \"\"\n    with pdfplumber.open(pdf_path) as pdf:\n        for page in pdf.pages:\n            page_text = page.extract_text()\n            if page_text:\n                text += page_text + \"\\n\"\n    return text.strip()\n```\n\n### Step 3: Fallback to Secondary Method (pypdfium2)\n\nIf pdfplumber returns empty or incomplete text:\n\n```python\nimport pdfium2\n\ndef extract_with_pypdfium2(pdf_path):\n    pdf = pdfium2.PdfDocument(pdf_path)\n    text = \"\"\n    for page in pdf:\n        text_page = page.get_textpage()\n        page_text = text_page.get_text_bounded()\n        if page_text:\n            text += page_text + \"\\n\"\n    return text.strip()\n```\n\n### Step 4: Fallback to Tertiary Method (pdftotext)\n\nIf pypdfium2 also fails, use command-line pdftotext:\n\n```bash\npdftotext \u002Fpath\u002Fto\u002Fdocument.pdf - 2>\u002Fdev\u002Fnull\n```\n\nOr in Python:\n\n```python\nimport subprocess\n\ndef extract_with_pdftotext(pdf_path):\n    result = subprocess.run(\n        ['pdftotext', pdf_path, '-'],\n        capture_output=True,\n        text=True\n    )\n    return result.stdout.strip()\n```\n\n### Step 5: Detect Scanned\u002FImage-Based PDFs\n\nAfter each extraction attempt, verify text was actually extracted:\n\n```python\ndef is_meaningful_text(text, min_chars=50):\n    \"\"\"Check if extracted text is meaningful (not empty or just whitespace)\"\"\"\n    if not text:\n        return False\n    # Remove whitespace and check length\n    cleaned = ''.join(text.split())\n    return len(cleaned) >= min_chars\n```\n\n### Step 6: OCR Fallback for Scanned Documents\n\nIf all text extraction methods return empty\u002Finsufficient text, the PDF is likely scanned. Use OCR:\n\n```python\nimport pdf2image\nimport pytesseract\nfrom PIL import Image\n\ndef extract_with_ocr(pdf_path, dpi=300):\n    \"\"\"Extract text from scanned PDFs using OCR\"\"\"\n    text = \"\"\n    images = pdf2image.convert_from_path(pdf_path, dpi=dpi)\n    for image in images:\n        page_text = pytesseract.image_to_string(image)\n        text += page_text + \"\\n\"\n    return text.strip()\n```\n\n## Complete Workflow Function\n\n```python\ndef robust_pdf_extract(pdf_path):\n    \"\"\"\n    Extract text from PDF using progressive fallback methods.\n    Returns (text, method_used) tuple.\n    \"\"\"\n    methods = [\n        (\"pdfplumber\", extract_with_pdfplumber),\n        (\"pypdfium2\", extract_with_pypdfium2),\n        (\"pdftotext\", extract_with_pdftotext),\n    ]\n    \n    for method_name, extract_func in methods:\n        try:\n            text = extract_func(pdf_path)\n            if is_meaningful_text(text):\n                return text, method_name\n        except Exception as e:\n            print(f\"{method_name} failed: {e}\")\n            continue\n    \n    # All text methods failed - try OCR\n    try:\n        text = extract_with_ocr(pdf_path)\n        if is_meaningful_text(text):\n            return text, \"ocr\"\n    except Exception as e:\n        print(f\"OCR failed: {e}\")\n    \n    return \"\", \"failed\"\n```\n\n## Dependencies\n\nInstall required packages:\n\n```bash\npip install pdfplumber pypdfium2 pdf2image pytesseract pillow\n# Also need system packages:\n# apt-get install poppler-utils tesseract-ocr  # Debian\u002FUbuntu\n# brew install poppler tesseract  # macOS\n```\n\n## Best Practices\n\n1. **Log which method succeeded** - helps identify document types for future optimization\n2. **Set reasonable character thresholds** - adjust `min_chars` based on expected document content\n3. **Handle exceptions gracefully** - each method may fail for different reasons\n4. **Consider DPI for OCR** - higher DPI (300+) improves accuracy but increases processing time\n5. **Cache results** - if processing same PDFs repeatedly, store successful extraction method per file\n\n## Troubleshooting\n\n| Symptom | Likely Cause | Solution |\n|---------|--------------|----------|\n| All methods return empty | Scanned PDF | OCR fallback should handle this |\n| pdfplumber fails with permission error | File locked or permissions issue | Check file permissions with `ls -la` |\n| OCR returns gibberish | Low quality scan or wrong language | Increase DPI, specify language in pytesseract |\n| pdftotext not found | Missing poppler-utils | Install system package |","# Robust PDF Extraction Workflow\n\nThis skill provides a systematic approach to extracting text from PDF files, handling both text-based and scanned\u002Fimage-based documents through progressive fallback methods.\n\n## When to Use\n\n- Processing PDFs of unknown or mixed types (text vs. scanned images)\n- Critical document processing where extraction failure is not acceptable\n- Batch processing multiple PDFs with varying formats\n\n## Workflow Steps\n\n### Step 1: Verify File Accessibility\n\nBefore attempting extraction, confirm the PDF exists and is readable:\n\n```bash\n# Check file exists and get basic info\nls -la \u002Fpath\u002Fto\u002Fdocument.pdf\n\n# Or search for files if location uncertain\nfind \u002Fpath -name \"*.pdf\" -type f 2>\u002Fdev\u002Fnull\n```\n\n### Step 2: Attempt Primary Extraction (pdfplumber)\n\nStart with pdfplumber for best text structure preservation:\n\n```python\nimport pdfplumber\n\ndef extract_with_pdfplumber(pdf_path):\n    text = \"\"\n    with pdfplumber.open(pdf_path) as pdf:\n        for page in pdf.pages:\n            page_text = page.extract_text()\n            if page_text:\n                text += page_text + \"\\n\"\n    return text.strip()\n```\n\n### Step 3: Fallback to Secondary Method (pypdfium2)\n\nIf pdfplumber returns empty or incomplete text:\n\n```python\nimport pdfium2\n\ndef extract_with_pypdfium2(pdf_path):\n    pdf = pdfium2.PdfDocument(pdf_path)\n    text = \"\"\n    for page in pdf:\n        text_page = page.get_textpage()\n        page_text = text_page.get_text_bounded()\n        if page_text:\n            text += page_text + \"\\n\"\n    return text.strip()\n```\n\n### Step 4: Fallback to Tertiary Method (pdftotext)\n\nIf pypdfium2 also fails, use command-line pdftotext:\n\n```bash\npdftotext \u002Fpath\u002Fto\u002Fdocument.pdf - 2>\u002Fdev\u002Fnull\n```\n\nOr in Python:\n\n```python\nimport subprocess\n\ndef extract_with_pdftotext(pdf_path):\n    result = subprocess.run(\n        ['pdftotext', pdf_path, '-'],\n        capture_output=True,\n        text=True\n    )\n    return result.stdout.strip()\n```\n\n### Step 5: Detect Scanned\u002FImage-Based PDFs\n\nAfter each extraction attempt, verify text was actually extracted:\n\n```python\ndef is_meaningful_text(text, min_chars=50):\n    \"\"\"Check if extracted text is meaningful (not empty or just whitespace)\"\"\"\n    if not text:\n        return False\n    # Remove whitespace and check length\n    cleaned = ''.join(text.split())\n    return len(cleaned) >= min_chars\n```\n\n### Step 6: OCR Fallback for Scanned Documents\n\nIf all text extraction methods return empty\u002Finsufficient text, the PDF is likely scanned. Use OCR:\n\n```python\nimport pdf2image\nimport pytesseract\nfrom PIL import Image\n\ndef extract_with_ocr(pdf_path, dpi=300):\n    \"\"\"Extract text from scanned PDFs using OCR\"\"\"\n    text = \"\"\n    images = pdf2image.convert_from_path(pdf_path, dpi=dpi)\n    for image in images:\n        page_text = pytesseract.image_to_string(image)\n        text += page_text + \"\\n\"\n    return text.strip()\n```\n\n## Complete Workflow Function\n\n```python\ndef robust_pdf_extract(pdf_path):\n    \"\"\"\n    Extract text from PDF using progressive fallback methods.\n    Returns (text, method_used) tuple.\n    \"\"\"\n    methods = [\n        (\"pdfplumber\", extract_with_pdfplumber),\n        (\"pypdfium2\", extract_with_pypdfium2),\n        (\"pdftotext\", extract_with_pdftotext),\n    ]\n    \n    for method_name, extract_func in methods:\n        try:\n            text = extract_func(pdf_path)\n            if is_meaningful_text(text):\n                return text, method_name\n        except Exception as e:\n            print(f\"{method_name} failed: {e}\")\n            continue\n    \n    # All text methods failed - try OCR\n    try:\n        text = extract_with_ocr(pdf_path)\n        if is_meaningful_text(text):\n            return text, \"ocr\"\n    except Exception as e:\n        print(f\"OCR failed: {e}\")\n    \n    return \"\", \"failed\"\n```\n\n## Dependencies\n\nInstall required packages:\n\n```bash\npip install pdfplumber pypdfium2 pdf2image pytesseract pillow\n# Also need system packages:\n# apt-get install poppler-utils tesseract-ocr  # Debian\u002FUbuntu\n# brew install poppler tesseract  # macOS\n```\n\n## Best Practices\n\n1. **Log which method succeeded** - helps identify document types for future optimization\n2. **Set reasonable character thresholds** - adjust `min_chars` based on expected document content\n3. **Handle exceptions gracefully** - each method may fail for different reasons\n4. **Consider DPI for OCR** - higher DPI (300+) improves accuracy but increases processing time\n5. **Cache results** - if processing same PDFs repeatedly, store successful extraction method per file\n\n## Troubleshooting\n\n| Symptom | Likely Cause | Solution |\n|---------|--------------|----------|\n| All methods return empty | Scanned PDF | OCR fallback should handle this |\n| pdfplumber fails with permission error | File locked or permissions issue | Check file permissions with `ls -la` |\n| OCR returns gibberish | Low quality scan or wrong language | Increase DPI, specify language in pytesseract |\n| pdftotext not found | Missing poppler-utils | Install system package |",{"name":5,"description":7},"main","0650921d63895de3997bc81f1ff1d0ac67032072","gdpval_bench\u002Fskills\u002Frobust-pdf-extraction","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution","https:\u002F\u002Fgithub.com\u002FUF-gzj","2026-04-16 09:31:03",{"source":8,"skillName":5,"commands":45,"prompt":55,"zipAvailable":56},[46,49,52],{"tool":47,"command":48},"npx","npx skills add UF-gzj\u002Fopenspace-claude-evolution --skill robust-pdf-extraction",{"tool":50,"command":51},"bunx","bunx skills add UF-gzj\u002Fopenspace-claude-evolution --skill robust-pdf-extraction",{"tool":53,"command":54},"pnpm","pnpm dlx skills add UF-gzj\u002Fopenspace-claude-evolution --skill robust-pdf-extraction","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Frobust-pdf-extraction\u002FSKILL.md",true,[58],{"path":59,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":62,"sourceHtmlUrl":63},".skill_id","OTHER","其他",35,"https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Frobust-pdf-extraction\u002F.skill_id",[65,89,105,114,144,160],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":33},"01M6XCCXD3NCM2YKR3WNGBASPC","write-special-chars-ts-check","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[72,73,74,75,76,77,78,79,32,80,81,82,83,84,85,86,87,88],"check","write","write special chars ts check","typescript","filters","characters","Existing","type-checking","errors","script","output","type","files","only","template","file","python",{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":33},"01M6XCCT7E3J922Q345PBGSHPN","write-special-chars-readback","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, with mandatory post-write verification via read_file and cleanup of \u002Ftmp helper scripts.","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[96,97,73,87,98,88,99,100,101,102,103,86,104,31,77,32,81],"readback","write special chars readback","helper","post","via","scripts","cleanup","read","verification",{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":33},"01M6XCCMQX1R8B6FECWB3P63T7","write-special-chars-heredoc","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) by using a Python heredoc script executed via shell.","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-heredoc\u002FSKILL.md",[],[112,73,77,113,81,100,86,87,88,32],"write special chars heredoc","shell",{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":125,"publishedAt":33},"01M6XCCG41M994JJEX6VN52PEP","worldmonitor-reference","Curated architecture index of the WorldMonitor open-source dashboard. Reference for extracting patterns — vanilla TypeScript, Panel class hierarchy, service layer, CSS grid, API edge functions, refresh scheduler, and 60+ data source integrations.","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fworldmonitor-reference\u002FSKILL.md",[120],{"categoryNo":121,"categoryName":122,"taxonomyType":123,"taxonomyTypeDesc":124},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[126,127,128,129,130,75,131,132,133,134,135,32,136,137,138,139,140,141,142,143],"reference","worldmonitor","worldmonitor reference","architecture","dashboard","css","scheduler","layer","hierarchy","source","extracting","panel","patterns","edge functions","integrations","open","api","data",{"skillNo":145,"name":146,"nameZh":6,"description":147,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":148,"categories":149,"keywords":150,"publishedAt":33},"01M6XCCCHWNKG2W4VH9E6A10HF","virtual-list","Implement efficient virtual scrolling for rendering large lists with DOM recycling, chunk-based rendering, and performance optimizations","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fvirtual-list\u002FSKILL.md",[],[151,152,153,154,32,155,31,156,157,158,159],"virtual list","list","virtual","chunk","dom","rendering","recycling","implement","performance",{"skillNo":161,"name":162,"nameZh":6,"description":163,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":164,"categories":165,"keywords":166,"publishedAt":33},"01M6XCC7X8PKMR2DEW91XGHYSV","verify-directory-structure","Diagnose and resolve file access issues by first verifying the directory structure.","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fverify-directory-structure\u002FSKILL.md",[],[167,168,169,170,171,172,87,173,174,175],"directory","verify directory structure","structure","verify","access","first","issues","diagnose","file access"]