[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KJB5K4AWNH2DY2QX1WPDS5":3,"skill-same:01M6KJB5K4AWNH2DY2QX1WPDS5":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},"01M6KJB5K4AWNH2DY2QX1WPDS5","pdf-extraction-fallback-7db3aa",null,"Resilient multi-tier PDF extraction with sequential fallback strategies when initial reading fails","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-7db3aa\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","fallback","pdf extraction","pdf extraction fallback 7db3aa","pdf extraction fallback","strategies","multi","with","reading","2026-11-10 10:12:30",false,"---\nname: pdf-extraction-fallback-7db3aa\ndescription: Resilient multi-tier PDF extraction with sequential fallback strategies when initial reading fails\n---\n\n# PDF Extraction Fallback Strategy\n\n## Purpose\n\nWhen processing complex documents (tax forms, legal documents, scanned materials), PDF extraction often fails on the first attempt. This skill provides a systematic fallback approach that tries multiple extraction methods in sequence until one succeeds.\n\n## When to Use\n\n- Initial PDF reading tools return errors or empty content\n- Document appears to be scanned\u002Fimage-based rather than text-based\n- Previous extraction attempts produced incomplete or garbled output\n- Working with forms, tables, or structured documents that need reliable extraction\n\n## Fallback Sequence\n\n### Tier 1: Shell-Based Extraction (pdftotext)\n\nStart with command-line tools that often handle edge cases better:\n\n```bash\n# Extract text maintaining layout\npdftotext -layout input.pdf output.txt\n\n# Extract raw text (faster, less formatting)\npdftotext input.pdf output.txt\n\n# Extract specific page range\npdftotext -f 1 -l 3 input.pdf output.txt\n```\n\nCheck if output contains meaningful content before proceeding.\n\n### Tier 2: Python-Based Parsing\n\nIf shell tools fail, use Python libraries with different extraction approaches:\n\n```python\n# Using PyPDF2 for basic text extraction\nimport PyPDF2\nwith open('document.pdf', 'rb') as f:\n    reader = PyPDF2.PdfReader(f)\n    text = ''.join(page.extract_text() for page in reader.pages)\n\n# Using pdfplumber for tables and structured content\nimport pdfplumber\nwith pdfplumber.open('document.pdf') as pdf:\n    for page in pdf.pages:\n        text = page.extract_text()\n        tables = page.extract_tables()\n\n# Using pypdf for newer PDF features\nfrom pypdf import PdfReader\nreader = PdfReader('document.pdf')\ntext = ''.join(page.extract_text() for page in reader.pages)\n```\n\n### Tier 3: OCR Tools (for Scanned Documents)\n\nIf the PDF contains images or scanned content, use OCR:\n\n```bash\n# Using tesseract via command line\ntesseract input.pdf output --psm 6\n\n# Using Python with pytesseract\nimport pytesseract\nfrom pdf2image import convert_from_path\n\nimages = convert_from_path('document.pdf')\ntext = ''.join(pytesseract.image_to_string(img) for img in images)\n```\n\n## Implementation Pattern\n\n```python\ndef extract_pdf_resilient(pdf_path):\n    \"\"\"Try multiple extraction methods until one succeeds.\"\"\"\n    \n    # Tier 1: Shell extraction\n    result = run_shell(f'pdftotext -layout \"{pdf_path}\" -')\n    if result.stdout and len(result.stdout.strip()) > 100:\n        return result.stdout, 'pdftotext'\n    \n    # Tier 2: Python libraries\n    try:\n        import pdfplumber\n        with pdfplumber.open(pdf_path) as pdf:\n            text = ''.join(page.extract_text() or '' for page in pdf.pages)\n        if text.strip():\n            return text, 'pdfplumber'\n    except Exception:\n        pass\n    \n    # Tier 3: OCR fallback\n    try:\n        from pdf2image import convert_from_path\n        import pytesseract\n        images = convert_from_path(pdf_path)\n        text = ''.join(pytesseract.image_to_string(img) for img in images)\n        if text.strip():\n            return text, 'tesseract-ocr'\n    except Exception:\n        pass\n    \n    raise ExtractionError(\"All extraction methods failed\")\n```\n\n## Decision Criteria\n\n| Indicator | Action |\n|-----------|--------|\n| Empty output | Proceed to next tier |\n| Garbled\u002Fspecial characters | Try next tier |\n| Partial content | Accept if meets minimum threshold |\n| Tool not available | Skip to next tier |\n| Format-specific errors | Try alternative library |\n\n## Best Practices\n\n1. **Validate each attempt** - Check output length and quality before accepting\n2. **Log which method succeeded** - Track which tier worked for future reference\n3. **Set minimum content thresholds** - Don't accept trivial results (e.g., \u003C50 chars)\n4. **Combine methods if needed** - Some documents need multiple approaches for different sections\n5. **Preserve original file** - Never modify the source PDF during extraction attempts\n\n## Error Handling\n\n- Catch exceptions at each tier, don't fail immediately\n- Log detailed error messages for debugging\n- Continue to next tier even if current tier partially succeeds but produces poor quality\n- After all tiers fail, provide clear summary of what was tried\n\n## Output Quality Check\n\nBefore declaring extraction complete:\n\n```python\ndef validate_extraction(text):\n    if not text or len(text.strip()) \u003C 50:\n        return False\n    if text.count('') > len(text) * 0.1:  # Too many replacement chars\n        return False\n    if len(set(text)) \u003C 10:  # Too little character variety\n        return False\n    return True\n```","# PDF Extraction Fallback Strategy\n\n## Purpose\n\nWhen processing complex documents (tax forms, legal documents, scanned materials), PDF extraction often fails on the first attempt. This skill provides a systematic fallback approach that tries multiple extraction methods in sequence until one succeeds.\n\n## When to Use\n\n- Initial PDF reading tools return errors or empty content\n- Document appears to be scanned\u002Fimage-based rather than text-based\n- Previous extraction attempts produced incomplete or garbled output\n- Working with forms, tables, or structured documents that need reliable extraction\n\n## Fallback Sequence\n\n### Tier 1: Shell-Based Extraction (pdftotext)\n\nStart with command-line tools that often handle edge cases better:\n\n```bash\n# Extract text maintaining layout\npdftotext -layout input.pdf output.txt\n\n# Extract raw text (faster, less formatting)\npdftotext input.pdf output.txt\n\n# Extract specific page range\npdftotext -f 1 -l 3 input.pdf output.txt\n```\n\nCheck if output contains meaningful content before proceeding.\n\n### Tier 2: Python-Based Parsing\n\nIf shell tools fail, use Python libraries with different extraction approaches:\n\n```python\n# Using PyPDF2 for basic text extraction\nimport PyPDF2\nwith open('document.pdf', 'rb') as f:\n    reader = PyPDF2.PdfReader(f)\n    text = ''.join(page.extract_text() for page in reader.pages)\n\n# Using pdfplumber for tables and structured content\nimport pdfplumber\nwith pdfplumber.open('document.pdf') as pdf:\n    for page in pdf.pages:\n        text = page.extract_text()\n        tables = page.extract_tables()\n\n# Using pypdf for newer PDF features\nfrom pypdf import PdfReader\nreader = PdfReader('document.pdf')\ntext = ''.join(page.extract_text() for page in reader.pages)\n```\n\n### Tier 3: OCR Tools (for Scanned Documents)\n\nIf the PDF contains images or scanned content, use OCR:\n\n```bash\n# Using tesseract via command line\ntesseract input.pdf output --psm 6\n\n# Using Python with pytesseract\nimport pytesseract\nfrom pdf2image import convert_from_path\n\nimages = convert_from_path('document.pdf')\ntext = ''.join(pytesseract.image_to_string(img) for img in images)\n```\n\n## Implementation Pattern\n\n```python\ndef extract_pdf_resilient(pdf_path):\n    \"\"\"Try multiple extraction methods until one succeeds.\"\"\"\n    \n    # Tier 1: Shell extraction\n    result = run_shell(f'pdftotext -layout \"{pdf_path}\" -')\n    if result.stdout and len(result.stdout.strip()) > 100:\n        return result.stdout, 'pdftotext'\n    \n    # Tier 2: Python libraries\n    try:\n        import pdfplumber\n        with pdfplumber.open(pdf_path) as pdf:\n            text = ''.join(page.extract_text() or '' for page in pdf.pages)\n        if text.strip():\n            return text, 'pdfplumber'\n    except Exception:\n        pass\n    \n    # Tier 3: OCR fallback\n    try:\n        from pdf2image import convert_from_path\n        import pytesseract\n        images = convert_from_path(pdf_path)\n        text = ''.join(pytesseract.image_to_string(img) for img in images)\n        if text.strip():\n            return text, 'tesseract-ocr'\n    except Exception:\n        pass\n    \n    raise ExtractionError(\"All extraction methods failed\")\n```\n\n## Decision Criteria\n\n| Indicator | Action |\n|-----------|--------|\n| Empty output | Proceed to next tier |\n| Garbled\u002Fspecial characters | Try next tier |\n| Partial content | Accept if meets minimum threshold |\n| Tool not available | Skip to next tier |\n| Format-specific errors | Try alternative library |\n\n## Best Practices\n\n1. **Validate each attempt** - Check output length and quality before accepting\n2. **Log which method succeeded** - Track which tier worked for future reference\n3. **Set minimum content thresholds** - Don't accept trivial results (e.g., \u003C50 chars)\n4. **Combine methods if needed** - Some documents need multiple approaches for different sections\n5. **Preserve original file** - Never modify the source PDF during extraction attempts\n\n## Error Handling\n\n- Catch exceptions at each tier, don't fail immediately\n- Log detailed error messages for debugging\n- Continue to next tier even if current tier partially succeeds but produces poor quality\n- After all tiers fail, provide clear summary of what was tried\n\n## Output Quality Check\n\nBefore declaring extraction complete:\n\n```python\ndef validate_extraction(text):\n    if not text or len(text.strip()) \u003C 50:\n        return False\n    if text.count('') > len(text) * 0.1:  # Too many replacement chars\n        return False\n    if len(set(text)) \u003C 10:  # Too little character variety\n        return False\n    return True\n```",{"name":5,"description":7},"main","ff671ef61ed6587c49bd54c81cdc751c0b99e363","gdpval_bench\u002Fskills\u002Fpdf-extraction-fallback-7db3aa","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 pdf-extraction-fallback-7db3aa",{"tool":51,"command":52},"bunx","bunx skills add AG064\u002FOpenSpace --skill pdf-extraction-fallback-7db3aa",{"tool":54,"command":55},"pnpm","pnpm dlx skills add AG064\u002FOpenSpace --skill pdf-extraction-fallback-7db3aa","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fpdf-extraction-fallback-7db3aa\u002FSKILL.md",true,[59],{"path":60,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":64},".skill_id","OTHER","其他",44,"https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fpdf-extraction-fallback-7db3aa\u002F.skill_id",[66,90,106,115,145,161],{"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,79,80,81,82,83,84,85,86,87,88,89],"write special chars ts check","check","write","filters","Existing","type-checking","for","errors","script","output","type","files","only","template","file","python","typescript",{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"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",[],[97,98,75,86,99,100,87,88,101,102,103,104,105,79,81,31],"readback","write special chars readback","cleanup","read","scripts","verification","via","post","helper",{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"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,113,88,79,103,86,114,87,81],"write special chars heredoc","shell",{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":126,"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",[121],{"categoryNo":122,"categoryName":123,"taxonomyType":124,"taxonomyTypeDesc":125},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[127,128,129,130,89,131,132,133,134,135,79,136,137,138,139,140,141,142,143,144],"reference","worldmonitor","worldmonitor reference","dashboard","css","architecture","extracting","hierarchy","source","layer","panel","patterns","edge functions","integrations","open","api","data","scheduler",{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":151,"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",[],[152,153,154,155,79,156,31,157,158,159,160],"virtual list","list","virtual","chunk","dom","rendering","recycling","implement","performance",{"skillNo":162,"name":163,"nameZh":6,"description":164,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":165,"categories":166,"keywords":167,"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",[],[168,169,170,171,172,173,87,174,175,176],"directory","verify","structure","verify directory structure","access","first","issues","diagnose","file access"]