[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KJCQX1CR4Z0JF739TC3B3Q":3,"skill-same:01M6KJCQX1CR4Z0JF739TC3B3Q":63},{"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":31,"linkOnly":32,"markdownContent":33,"markdownBody":34,"frontMatter":35,"refName":36,"commitSha":37,"skillDirectory":38,"forksCount":13,"repositoryHtmlUrl":39,"repositoryHomepageUrl":6,"ownerHtmlUrl":40,"ownerBlogUrl":6,"ownerDescription":41,"updatedAt":42,"install":43,"resources":56},"01M6KJCQX1CR4Z0JF739TC3B3Q","pdf-text-extraction-9424c5",null,"Extract text from PDF files using pdftotext when read_file returns binary data","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-text-extraction-9424c5\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30],"PDF","extraction","text","pdf text extraction 9424c5","pdf text extraction","file","data","returns","read","extract","files","binary","pdftotext","2026-11-10 10:12:30",false,"---\nname: pdf-text-extraction-9424c5\ndescription: Extract text from PDF files using pdftotext when read_file returns binary data\n---\n\n# PDF Text Extraction via pdftotext\n\n## Problem\n\nWhen using `read_file` on PDF documents, the function may return binary image data or garbled content instead of readable text. This occurs because PDFs can contain scanned images or complex binary structures that `read_file` cannot properly parse as text.\n\n## Solution\n\nUse the `pdftotext` command-line utility via `run_shell` to extract clean text content from PDF files.\n\n## Steps\n\n### 1. Verify PDF file exists\n\n```python\nimport os\n\npdf_path = \"path\u002Fto\u002Fdocument.pdf\"\nif not os.path.exists(pdf_path):\n    raise FileNotFoundError(f\"PDF not found: {pdf_path}\")\n```\n\n### 2. Extract text using pdftotext\n\n```python\nfrom tools import run_shell\n\n# Extract text to stdout\nresult = run_shell(command=f\"pdftotext '{pdf_path}' -\", timeout=60)\npdf_text = result.stdout\n\n# Alternative: extract to a temporary file\ntemp_txt = \"\u002Ftmp\u002Fextracted.txt\"\nrun_shell(command=f\"pdftotext '{pdf_path}' '{temp_txt}'\", timeout=60)\nwith open(temp_txt, 'r') as f:\n    pdf_text = f.read()\n```\n\n### 3. Handle parameter naming carefully\n\nWhen calling `read_file`, be aware of the parameter name:\n- Use `filetype=\"pdf\"` (not `file_type`)\n- Some tool implementations may use different parameter names\n\n```python\n# Correct parameter usage\ncontent = read_file(file_path=\"doc.pdf\", filetype=\"pdf\")\n\n# If this returns binary\u002Fgarbled data, fall back to pdftotext\n```\n\n## Common pdftotext Options\n\n| Option | Description |\n|--------|-------------|\n| `-` | Output to stdout |\n| `-layout` | Maintain original layout |\n| `-f \u003Cn>` | Start from page n |\n| `-l \u003Cn>` | End at page n |\n| `-q` | Quiet mode |\n\nExample with options:\n```python\nresult = run_shell(command=f\"pdftotext -layout -q '{pdf_path}' -\", timeout=60)\n```\n\n## Error Handling\n\n```python\nfrom tools import run_shell\n\ndef extract_pdf_text(pdf_path):\n    \"\"\"Extract text from PDF using pdftotext with error handling.\"\"\"\n    import os\n    \n    if not os.path.exists(pdf_path):\n        raise FileNotFoundError(f\"PDF not found: {pdf_path}\")\n    \n    result = run_shell(command=f\"pdftotext '{pdf_path}' -\", timeout=60)\n    \n    if result.returncode != 0:\n        raise RuntimeError(f\"pdftotext failed: {result.stderr}\")\n    \n    return result.stdout.strip()\n```\n\n## When to Use This Pattern\n\n- `read_file` returns binary data, garbled text, or image content for a PDF\n- You need searchable\u002Fprocessable text from PDF documents\n- The PDF contains text (not just scanned images - for those, consider OCR tools)\n\n## Prerequisites\n\n- `pdftotext` must be installed (part of `poppler-utils` on Debian\u002FUbuntu, `poppler` on macOS via Homebrew)\n- Verify availability: `run_shell(command=\"which pdftotext\")`","# PDF Text Extraction via pdftotext\n\n## Problem\n\nWhen using `read_file` on PDF documents, the function may return binary image data or garbled content instead of readable text. This occurs because PDFs can contain scanned images or complex binary structures that `read_file` cannot properly parse as text.\n\n## Solution\n\nUse the `pdftotext` command-line utility via `run_shell` to extract clean text content from PDF files.\n\n## Steps\n\n### 1. Verify PDF file exists\n\n```python\nimport os\n\npdf_path = \"path\u002Fto\u002Fdocument.pdf\"\nif not os.path.exists(pdf_path):\n    raise FileNotFoundError(f\"PDF not found: {pdf_path}\")\n```\n\n### 2. Extract text using pdftotext\n\n```python\nfrom tools import run_shell\n\n# Extract text to stdout\nresult = run_shell(command=f\"pdftotext '{pdf_path}' -\", timeout=60)\npdf_text = result.stdout\n\n# Alternative: extract to a temporary file\ntemp_txt = \"\u002Ftmp\u002Fextracted.txt\"\nrun_shell(command=f\"pdftotext '{pdf_path}' '{temp_txt}'\", timeout=60)\nwith open(temp_txt, 'r') as f:\n    pdf_text = f.read()\n```\n\n### 3. Handle parameter naming carefully\n\nWhen calling `read_file`, be aware of the parameter name:\n- Use `filetype=\"pdf\"` (not `file_type`)\n- Some tool implementations may use different parameter names\n\n```python\n# Correct parameter usage\ncontent = read_file(file_path=\"doc.pdf\", filetype=\"pdf\")\n\n# If this returns binary\u002Fgarbled data, fall back to pdftotext\n```\n\n## Common pdftotext Options\n\n| Option | Description |\n|--------|-------------|\n| `-` | Output to stdout |\n| `-layout` | Maintain original layout |\n| `-f \u003Cn>` | Start from page n |\n| `-l \u003Cn>` | End at page n |\n| `-q` | Quiet mode |\n\nExample with options:\n```python\nresult = run_shell(command=f\"pdftotext -layout -q '{pdf_path}' -\", timeout=60)\n```\n\n## Error Handling\n\n```python\nfrom tools import run_shell\n\ndef extract_pdf_text(pdf_path):\n    \"\"\"Extract text from PDF using pdftotext with error handling.\"\"\"\n    import os\n    \n    if not os.path.exists(pdf_path):\n        raise FileNotFoundError(f\"PDF not found: {pdf_path}\")\n    \n    result = run_shell(command=f\"pdftotext '{pdf_path}' -\", timeout=60)\n    \n    if result.returncode != 0:\n        raise RuntimeError(f\"pdftotext failed: {result.stderr}\")\n    \n    return result.stdout.strip()\n```\n\n## When to Use This Pattern\n\n- `read_file` returns binary data, garbled text, or image content for a PDF\n- You need searchable\u002Fprocessable text from PDF documents\n- The PDF contains text (not just scanned images - for those, consider OCR tools)\n\n## Prerequisites\n\n- `pdftotext` must be installed (part of `poppler-utils` on Debian\u002FUbuntu, `poppler` on macOS via Homebrew)\n- Verify availability: `run_shell(command=\"which pdftotext\")`",{"name":5,"description":7},"main","ff671ef61ed6587c49bd54c81cdc751c0b99e363","gdpval_bench\u002Fskills\u002Fpdf-text-extraction-9424c5","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":44,"prompt":54,"zipAvailable":55},[45,48,51],{"tool":46,"command":47},"npx","npx skills add AG064\u002FOpenSpace --skill pdf-text-extraction-9424c5",{"tool":49,"command":50},"bunx","bunx skills add AG064\u002FOpenSpace --skill pdf-text-extraction-9424c5",{"tool":52,"command":53},"pnpm","pnpm dlx skills add AG064\u002FOpenSpace --skill pdf-text-extraction-9424c5","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fpdf-text-extraction-9424c5\u002FSKILL.md",true,[57],{"path":58,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":61,"sourceHtmlUrl":62},".skill_id","OTHER","其他",40,"https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fpdf-text-extraction-9424c5\u002F.skill_id",[64,86,102,111,135,151],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":31},"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",[],[71,72,73,74,75,76,77,78,79,80,81,28,82,83,23,84,85],"write special chars ts check","check","write","filters","Existing","type-checking","for","errors","script","output","type","only","template","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":31},"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,73,83,95,26,23,84,96,97,98,99,100,77,79,101],"readback","write special chars readback","cleanup","scripts","verification","via","post","helper","with",{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":31},"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",[],[73,109,84,77,98,83,110,23,79],"write special chars heredoc","shell",{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":31},"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",[],[118,119,120,121,85,122,123,124,125,126,77,127,128,129,130,131,132,133,24,134],"reference","worldmonitor","worldmonitor reference","dashboard","css","architecture","extracting","hierarchy","source","layer","panel","patterns","edge functions","integrations","open","api","scheduler",{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":141,"publishedAt":31},"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",[],[142,143,144,145,77,146,101,147,148,149,150],"virtual list","list","virtual","chunk","dom","rendering","recycling","implement","performance",{"skillNo":152,"name":153,"nameZh":6,"description":154,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":155,"categories":156,"keywords":157,"publishedAt":31},"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",[],[158,159,160,161,162,163,23,164,165,166],"directory","verify","structure","verify directory structure","access","first","issues","diagnose","file access"]