[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KJBG3F49JCMRFX7J25W0NR":3,"skill-same:01M6KJBG3F49JCMRFX7J25W0NR":62},{"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":17,"publishedAt":30,"linkOnly":31,"markdownContent":32,"markdownBody":33,"frontMatter":34,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":13,"repositoryHtmlUrl":38,"repositoryHomepageUrl":6,"ownerHtmlUrl":39,"ownerBlogUrl":6,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M6KJBG3F49JCMRFX7J25W0NR","pdf-extraction-fallback",null,"Multi-stage fallback strategy for PDF\u002Fdocument extraction using sequential tool alternatives","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\u002Fpdf-extraction-fallback\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29],"PDF","extraction","fallback","pdf extraction","pdf extraction fallback","tool","strategy","document","stage","multi","for","alternatives","2026-11-10 10:12:30",false,"---\nname: pdf-extraction-fallback\ndescription: Multi-stage fallback strategy for PDF\u002Fdocument extraction using sequential tool alternatives\n---\n\n# PDF Extraction Fallback Strategy\n\nWhen processing documents (especially PDFs), initial extraction attempts may fail due to formatting, encryption, or tool limitations. This skill provides a systematic fallback approach that tries multiple extraction methods before declaring failure.\n\n## Core Principle\n\n**Never declare completion after a single tool failure.** Instead, iterate through a hierarchy of extraction methods, each with different capabilities and limitations.\n\n## Fallback Hierarchy\n\nAttempt extraction methods in this order:\n\n### Stage 1: Direct PDF Reading\nTry native PDF libraries first (fastest, preserves structure):\n```python\nimport PyPDF2\nfrom pypdf import PdfReader\n\ndef extract_with_pypdf(pdf_path):\n    reader = PdfReader(pdf_path)\n    text = \"\"\n    for page in reader.pages:\n        text += page.extract_text() or \"\"\n    return text\n```\n\n### Stage 2: Shell-based Extraction (pdftotext)\nIf Stage 1 fails, use system tools:\n```bash\n# Install if needed: apt-get install poppler-utils\npdftotext -layout input.pdf output.txt\npdftotext -raw input.pdf output.txt  # Alternative layout\n```\n\n```python\nimport subprocess\n\ndef extract_with_pdftotext(pdf_path):\n    result = subprocess.run(\n        ['pdftotext', '-layout', pdf_path, '-'],\n        capture_output=True, text=True\n    )\n    if result.returncode == 0:\n        return result.stdout\n    raise Exception(\"pdftotext failed\")\n```\n\n### Stage 3: Alternative Python Parsers\nTry different Python libraries with varying capabilities:\n```python\n# pdfplumber - better for tables\nimport pdfplumber\ndef extract_with_pdfplumber(pdf_path):\n    text = \"\"\n    with pdfplumber.open(pdf_path) as pdf:\n        for page in pdf.pages:\n            text += page.extract_text() or \"\"\n    return text\n\n# pdfminer - handles complex layouts\nfrom pdfminer.high_level import extract_text\ndef extract_with_pdfminer(pdf_path):\n    return extract_text(pdf_path)\n```\n\n### Stage 4: OCR Fallback\nFor scanned images or when text extraction fails:\n```bash\n# Using tesseract\nconvert input.pdf output-%d.png  # Convert to images first\ntesseract output-0.png result --psm 6\n```\n\n```python\n# Using pytesseract\nfrom pdf2image import convert_from_path\nimport pytesseract\n\ndef extract_with_ocr(pdf_path):\n    images = convert_from_path(pdf_path, dpi=300)\n    text = \"\"\n    for image in images:\n        text += pytesseract.image_to_string(image)\n    return text\n```\n\n## Implementation Pattern\n\n```python\ndef robust_pdf_extraction(pdf_path):\n    \"\"\"Try multiple extraction methods until one succeeds.\"\"\"\n    \n    extraction_methods = [\n        (\"PyPDF2\", extract_with_pypdf),\n        (\"pdftotext\", extract_with_pdftotext),\n        (\"pdfplumber\", extract_with_pdfplumber),\n        (\"pdfminer\", extract_with_pdfminer),\n        (\"OCR\", extract_with_ocr),\n    ]\n    \n    errors = []\n    for method_name, method_func in extraction_methods:\n        try:\n            print(f\"Trying {method_name}...\")\n            text = method_func(pdf_path)\n            if text and text.strip():\n                print(f\"Success with {method_name}\")\n                return text\n            else:\n                errors.append(f\"{method_name}: empty result\")\n        except Exception as e:\n            errors.append(f\"{method_name}: {str(e)}\")\n            print(f\"{method_name} failed: {e}\")\n            continue\n    \n    # All methods failed\n    raise Exception(f\"All extraction methods failed:\\n\" + \"\\n\".join(errors))\n```\n\n## Success Criteria\n\nA method is considered successful when:\n1. **No exceptions** are raised during execution\n2. **Non-empty text** is returned (text.strip() has content)\n3. **Content quality** meets task requirements (check for expected keywords\u002Fpatterns)\n\n## Best Practices\n\n1. **Log each attempt** - Record which methods were tried and why they failed\n2. **Validate output** - Check extracted text contains expected content markers\n3. **Graceful degradation** - Proceed with partial data if full extraction isn't possible\n4. **Cache successful method** - Remember which method worked for similar files\n5. **Set timeouts** - Prevent OCR or complex parsing from hanging indefinitely\n\n## Common Failure Modes\n\n| Symptom | Likely Cause | Best Fallback |\n|---------|--------------|---------------|\n| Empty pages | Image-based PDF | OCR (Stage 4) |\n| Garbled text | Encoding issues | pdftotext (Stage 2) |\n| Missing tables | Simple parser | pdfplumber (Stage 3) |\n| Permission errors | Encrypted PDF | Check password\u002Fpermissions first |\n| Layout lost | Complex formatting | pdftotext -layout or pdfplumber |\n\n## When to Use\n\n- Processing unknown\u002Funtrusted PDF sources\n- Batch processing diverse document types\n- Critical tasks where extraction failure is not acceptable\n- Documents with mixed content (text + images + tables)","# PDF Extraction Fallback Strategy\n\nWhen processing documents (especially PDFs), initial extraction attempts may fail due to formatting, encryption, or tool limitations. This skill provides a systematic fallback approach that tries multiple extraction methods before declaring failure.\n\n## Core Principle\n\n**Never declare completion after a single tool failure.** Instead, iterate through a hierarchy of extraction methods, each with different capabilities and limitations.\n\n## Fallback Hierarchy\n\nAttempt extraction methods in this order:\n\n### Stage 1: Direct PDF Reading\nTry native PDF libraries first (fastest, preserves structure):\n```python\nimport PyPDF2\nfrom pypdf import PdfReader\n\ndef extract_with_pypdf(pdf_path):\n    reader = PdfReader(pdf_path)\n    text = \"\"\n    for page in reader.pages:\n        text += page.extract_text() or \"\"\n    return text\n```\n\n### Stage 2: Shell-based Extraction (pdftotext)\nIf Stage 1 fails, use system tools:\n```bash\n# Install if needed: apt-get install poppler-utils\npdftotext -layout input.pdf output.txt\npdftotext -raw input.pdf output.txt  # Alternative layout\n```\n\n```python\nimport subprocess\n\ndef extract_with_pdftotext(pdf_path):\n    result = subprocess.run(\n        ['pdftotext', '-layout', pdf_path, '-'],\n        capture_output=True, text=True\n    )\n    if result.returncode == 0:\n        return result.stdout\n    raise Exception(\"pdftotext failed\")\n```\n\n### Stage 3: Alternative Python Parsers\nTry different Python libraries with varying capabilities:\n```python\n# pdfplumber - better for tables\nimport pdfplumber\ndef extract_with_pdfplumber(pdf_path):\n    text = \"\"\n    with pdfplumber.open(pdf_path) as pdf:\n        for page in pdf.pages:\n            text += page.extract_text() or \"\"\n    return text\n\n# pdfminer - handles complex layouts\nfrom pdfminer.high_level import extract_text\ndef extract_with_pdfminer(pdf_path):\n    return extract_text(pdf_path)\n```\n\n### Stage 4: OCR Fallback\nFor scanned images or when text extraction fails:\n```bash\n# Using tesseract\nconvert input.pdf output-%d.png  # Convert to images first\ntesseract output-0.png result --psm 6\n```\n\n```python\n# Using pytesseract\nfrom pdf2image import convert_from_path\nimport pytesseract\n\ndef extract_with_ocr(pdf_path):\n    images = convert_from_path(pdf_path, dpi=300)\n    text = \"\"\n    for image in images:\n        text += pytesseract.image_to_string(image)\n    return text\n```\n\n## Implementation Pattern\n\n```python\ndef robust_pdf_extraction(pdf_path):\n    \"\"\"Try multiple extraction methods until one succeeds.\"\"\"\n    \n    extraction_methods = [\n        (\"PyPDF2\", extract_with_pypdf),\n        (\"pdftotext\", extract_with_pdftotext),\n        (\"pdfplumber\", extract_with_pdfplumber),\n        (\"pdfminer\", extract_with_pdfminer),\n        (\"OCR\", extract_with_ocr),\n    ]\n    \n    errors = []\n    for method_name, method_func in extraction_methods:\n        try:\n            print(f\"Trying {method_name}...\")\n            text = method_func(pdf_path)\n            if text and text.strip():\n                print(f\"Success with {method_name}\")\n                return text\n            else:\n                errors.append(f\"{method_name}: empty result\")\n        except Exception as e:\n            errors.append(f\"{method_name}: {str(e)}\")\n            print(f\"{method_name} failed: {e}\")\n            continue\n    \n    # All methods failed\n    raise Exception(f\"All extraction methods failed:\\n\" + \"\\n\".join(errors))\n```\n\n## Success Criteria\n\nA method is considered successful when:\n1. **No exceptions** are raised during execution\n2. **Non-empty text** is returned (text.strip() has content)\n3. **Content quality** meets task requirements (check for expected keywords\u002Fpatterns)\n\n## Best Practices\n\n1. **Log each attempt** - Record which methods were tried and why they failed\n2. **Validate output** - Check extracted text contains expected content markers\n3. **Graceful degradation** - Proceed with partial data if full extraction isn't possible\n4. **Cache successful method** - Remember which method worked for similar files\n5. **Set timeouts** - Prevent OCR or complex parsing from hanging indefinitely\n\n## Common Failure Modes\n\n| Symptom | Likely Cause | Best Fallback |\n|---------|--------------|---------------|\n| Empty pages | Image-based PDF | OCR (Stage 4) |\n| Garbled text | Encoding issues | pdftotext (Stage 2) |\n| Missing tables | Simple parser | pdfplumber (Stage 3) |\n| Permission errors | Encrypted PDF | Check password\u002Fpermissions first |\n| Layout lost | Complex formatting | pdftotext -layout or pdfplumber |\n\n## When to Use\n\n- Processing unknown\u002Funtrusted PDF sources\n- Batch processing diverse document types\n- Critical tasks where extraction failure is not acceptable\n- Documents with mixed content (text + images + tables)",{"name":5,"description":7},"main","ff671ef61ed6587c49bd54c81cdc751c0b99e363","gdpval_bench\u002Fskills\u002Fpdf-extraction-fallback","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":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add AG064\u002FOpenSpace --skill pdf-extraction-fallback",{"tool":48,"command":49},"bunx","bunx skills add AG064\u002FOpenSpace --skill pdf-extraction-fallback",{"tool":51,"command":52},"pnpm","pnpm dlx skills add AG064\u002FOpenSpace --skill pdf-extraction-fallback","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fpdf-extraction-fallback\u002FSKILL.md",true,[56],{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},".skill_id","OTHER","其他",37,"https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fpdf-extraction-fallback\u002F.skill_id",[63,86,103,112,137,153],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":30},"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",[],[70,71,72,73,74,75,28,76,77,78,79,80,81,82,83,84,85],"write special chars ts check","check","write","filters","Existing","type-checking","errors","script","output","type","files","only","template","file","python","typescript",{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":30},"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",[],[93,94,72,82,95,96,83,84,97,98,99,100,101,28,77,102],"readback","write special chars readback","cleanup","read","scripts","verification","via","post","helper","with",{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":30},"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",[],[72,110,84,28,99,82,111,83,77],"write special chars heredoc","shell",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":30},"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",[],[119,120,121,122,85,123,124,125,126,127,28,128,129,130,131,132,133,134,135,136],"reference","worldmonitor","worldmonitor reference","dashboard","css","architecture","extracting","hierarchy","source","layer","panel","patterns","edge functions","integrations","open","api","data","scheduler",{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":143,"publishedAt":30},"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",[],[144,145,146,147,28,148,102,149,150,151,152],"virtual list","list","virtual","chunk","dom","rendering","recycling","implement","performance",{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":157,"categories":158,"keywords":159,"publishedAt":30},"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",[],[160,161,162,163,164,165,83,166,167,168],"directory","verify","structure","verify directory structure","access","first","issues","diagnose","file access"]