[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KJXD64Q1RMFPS9SZ847V9P":3,"skill-same:01M6KJXD64Q1RMFPS9SZ847V9P":65},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"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":43,"updatedAt":44,"install":45,"resources":58},"01M6KJXD64Q1RMFPS9SZ847V9P","robust-pdf-extraction",null,"Multi-method PDF extraction with sequential fallback and OCR for scanned documents","AG064\u002FOpenSpace","AG064","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184930299?v=4","01M6KHVFG7TB73NHX3RDYSTMH2","01M6KHVFMM7XA2PZA9Z83PHS3V",0,"MIT","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\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","ff671ef61ed6587c49bd54c81cdc751c0b99e363","gdpval_bench\u002Fskills\u002Frobust-pdf-extraction","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace","https:\u002F\u002Fgithub.com\u002FAG064","AG064, E.Mi.\r\n\r\nA person who thinks all the time, yet all they have to think about is nothing. I want to improve the world and work on open source projects","2026-10-08 06:53:48",{"source":8,"skillName":5,"commands":46,"prompt":56,"zipAvailable":57},[47,50,53],{"tool":48,"command":49},"npx","npx skills add AG064\u002FOpenSpace --skill robust-pdf-extraction",{"tool":51,"command":52},"bunx","bunx skills add AG064\u002FOpenSpace --skill robust-pdf-extraction",{"tool":54,"command":55},"pnpm","pnpm dlx skills add AG064\u002FOpenSpace --skill robust-pdf-extraction","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Frobust-pdf-extraction\u002FSKILL.md",true,[59],{"path":60,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":64},".skill_id","OTHER","其他",35,"https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Frobust-pdf-extraction\u002F.skill_id",[66,89,105,114,144,160],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":33},"01M6KKMPWA0B5SCCH766F8M5EA","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\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[73,74,75,76,77,78,32,79,80,81,82,83,84,85,86,87,88],"write special chars ts check","check","write","filters","Existing","type-checking","errors","script","output","type","files","only","template","file","python","typescript",{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":33},"01M6KKMJXVBNVEY3TRK055F4A7","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\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[96,97,75,85,98,99,86,87,100,101,102,103,104,32,80,31],"readback","write special chars readback","cleanup","read","scripts","verification","via","post","helper",{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":33},"01M6KKMEGX9M9NC105J0W3Q5B9","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\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-heredoc\u002FSKILL.md",[],[75,112,87,32,102,85,113,86,80],"write special chars heredoc","shell",{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":125,"publishedAt":33},"01M6KKM8EJ2AATVHZBNB916WT0","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\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fworldmonitor-reference\u002FSKILL.md",[120],{"categoryNo":121,"categoryName":122,"taxonomyType":123,"taxonomyTypeDesc":124},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[126,127,128,129,88,130,131,132,133,134,32,135,136,137,138,139,140,141,142,143],"reference","worldmonitor","worldmonitor reference","dashboard","css","architecture","extracting","hierarchy","source","layer","panel","patterns","edge functions","integrations","open","api","data","scheduler",{"skillNo":145,"name":146,"nameZh":6,"description":147,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":148,"categories":149,"keywords":150,"publishedAt":33},"01M6KKM39PHYK627F19GE2B9XN","virtual-list","Implement efficient virtual scrolling for rendering large lists with DOM recycling, chunk-based rendering, and performance optimizations","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\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":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":164,"categories":165,"keywords":166,"publishedAt":33},"01M6KKKY7T2P61Y0JH54CDEJKQ","verify-directory-structure","Diagnose and resolve file access issues by first verifying the directory structure.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fverify-directory-structure\u002FSKILL.md",[],[167,168,169,170,171,172,86,173,174,175],"directory","verify","structure","verify directory structure","access","first","issues","diagnose","file access"]