用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/HKUDS/OpenSpace --skill pdf-text-extraction-fallback命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | pdf-text-extraction-fallback |
| description | Extract text from PDFs using pdftotext when read_file returns binary data |
Use this skill when read_file with filetype="pdf" returns binary/image data instead of readable text content. This is a common issue with PDF files that contain embedded images or complex formatting.
Before attempting extraction, ensure you're using the correct parameter name:
filetype (not file_type) for the read_file function# Correct
read_file(filetype="pdf", file_path="document.pdf")
# Incorrect - may fail silently
read_file(file_type="pdf", file_path="document.pdf")
After calling read_file, check if the result contains:
b'...' byte strings with non-text content)If yes, proceed with the pdftotext workaround.
Use run_shell to call pdftotext, which extracts text directly from PDF files:
# Extract text to stdout
result = run_shell(command="pdftotext /path/to/document.pdf -")
text_content = result.stdout
The - flag tells pdftotext to output to stdout instead of creating a file.
result = run_shell(command="pdftotext /path/to/document.pdf -")
if result.stderr:
# Check for errors like "pdftotext not found"
# May need to install poppler-utils
pass
text_content = result.stdout
# text_content now contains the extracted text
# Step 1: Try normal read with correct parameters
content = read_file(filetype="pdf", file_path="reference.pdf")
# Step 2: Check if content is readable
if not content or looks_like_binary(content):
# Step 3: Fall back to pdftotext
result = run_shell(command="pdftotext reference.pdf -")
text_content = result.stdout
# Step 4: Verify extraction succeeded
if result.stderr:
# Handle error (e.g., install pdftotext)
pass
pdftotext is part of the poppler-utils package:
apt-get install poppler-utilsbrew install popplerIf stdout approach has issues, output to a temporary file:
run_shell(command="pdftotext /path/to/document.pdf /tmp/output.txt")
text_content = read_file(filetype="txt", file_path="/tmp/output.txt")
filetype parameter spelling before troubleshooting