用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/HKUDS/OpenSpace --skill pdf-text-extraction-9424c5命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Incremental audio production with duration mismatch handling, adaptive stem extension, and pre-mix alignment verification
Audio production with diagnostic analysis, timecode parsing from documents, and verified export workflow
Incremental audio production with duration alignment handling, per-stem verification, and adaptive extension strategies
基于 SOC 职业分类
正在显示 SKILL.md
| name | pdf-text-extraction-9424c5 |
| description | Extract text from PDF files using pdftotext when read_file returns binary data |
When 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.
Use the pdftotext command-line utility via run_shell to extract clean text content from PDF files.
import os
pdf_path = "path/to/document.pdf"
if not os.path.exists(pdf_path):
raise FileNotFoundError(f"PDF not found: {pdf_path}")
from tools import run_shell
# Extract text to stdout
result = run_shell(command=f"pdftotext '{pdf_path}' -", timeout=60)
pdf_text = result.stdout
# Alternative: extract to a temporary file
temp_txt = "/tmp/extracted.txt"
run_shell(command=f"pdftotext '{pdf_path}' '{temp_txt}'", timeout=60)
with open(temp_txt, 'r') as f:
pdf_text = f.read()
When calling read_file, be aware of the parameter name:
filetype="pdf" (not file_type)# Correct parameter usage
content = read_file(file_path="doc.pdf", filetype="pdf")
# If this returns binary/garbled data, fall back to pdftotext
| Option | Description |
|---|---|
- | Output to stdout |
-layout | Maintain original layout |
-f <n> | Start from page n |
-l <n> | End at page n |
-q | Quiet mode |
Example with options:
result = run_shell(command=f"pdftotext -layout -q '{pdf_path}' -", timeout=60)
from tools import run_shell
def extract_pdf_text(pdf_path):
"""Extract text from PDF using pdftotext with error handling."""
import os
if not os.path.exists(pdf_path):
raise FileNotFoundError(f"PDF not found: {pdf_path}")
result = run_shell(command=f"pdftotext '{pdf_path}' -", timeout=60)
if result.returncode != 0:
raise RuntimeError(f"pdftotext failed: {result.stderr}")
return result.stdout.strip()
read_file returns binary data, garbled text, or image content for a PDFpdftotext must be installed (part of poppler-utils on Debian/Ubuntu, poppler on macOS via Homebrew)run_shell(command="which pdftotext")