pdf-extract-progressive-tools
Fungsinya
Skill ini menetapkan urutan langkah demi langkah untuk mengekstrak teks PDF ketika metode pertama mengembalikan data yang tidak bisa dibaca. Skill ini cocok untuk orang yang AI-nya menerima keluaran biner atau rusak dari PDF.
Kapan dipakai
- ✓Saat membaca PDF mengembalikan data biner atau gambar, bukan teks.
- ✓Saat saya membutuhkan teks PDF yang andal untuk diringkas atau dianalisis.
- ✓Saat filenya adalah PDF yang kompleks dan alat sederhana tidak bisa membacanya.
Link skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-download-extract-fallback-enhanced-899f5b/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
“AI terus mendapatkan teks yang rusak dari PDF saya. Coba cara yang paling mudah dulu, lalu alat lain secara berurutan sampai mendapat teks yang bersih.”
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
AI mencoba pembacaan file sederhana, lalu menjalankan pdftotext dari shell jika itu gagal, dan terakhir memakai skrip PyMuPDF Python di dalam sandbox, sambil memeriksa kualitas teks di akhir.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
PDF Text Extraction with Progressive Tool Fallback
This skill provides a robust workflow for extracting text from PDF documents using a sequenced approach with agent tools, with explicit fallback mechanisms based on observed tool behavior.
Critical Insight from Execution Data
read_file often returns binary/image data for PDFs, not extracted text. When this occurs, immediately escalate to run_shell with pdftotext before attempting Python-based extraction.
Entry Point: Determine Your Starting Point
Before beginning, identify your scenario:
| Scenario | Start Here | Skip |
|---|---|---|
| PDF already on local disk | Step 1 (read_file attempt) | Download steps |
| PDF at a web URL | Download first, then Step 1 | None |
| PDF content already extracted | Step 4 (Quality verification) | Steps 1-3 |
Overview
PDF extraction failures cascade when tool sequencing is unclear. This workflow ensures maximum success rate through explicit tool progression:
- read_file - Quick attempt, but may return binary data
- run_shell + pdftotext - Reliable extraction when read_file fails
- execute_code_sandbox + PyMuPDF - Final fallback for complex PDFs
Step-by-Step Instructions
Step 1: Attempt read_file First
Always try the simplest approach first:
Tool: read_file
Path: document.pdf
Expected outcome: Extracted text content
Critical check: Examine the returned content:
- ✅ Text visible: Proceed to Step 4 (Quality verification)
- ⚠️ Binary/image data detected: Immediately proceed to Step 2
- ❌ File not found: Verify path or download first
Binary data indicators:
- Content starts with
%PDF-header without text extraction - Content appears as garbled characters or base64
- Content contains PNG/JPEG markers within PDF wrapper
- File size seems reasonable but no readable text
Step 2: Escalate to run_shell with pdftotext
When read_file returns binary data, do NOT attempt execute_code_sandbox yet. Use run_shell immediately:
Tool: run_shell
Command: pdftotext document.pdf document.txt
If pdftotext is not available:
Tool: run_shell
Command: apt-get update && apt-get install -y poppler-utils && pdftotext document.pdf document.txt
Then read the extracted text:
Tool: read_file
Path: document.txt
Expected outcome: Clean text extraction
If this fails:
- Check if file is password-protected
- Check if file is corrupted (run
file document.pdf) - Proceed to Step 3
Step 3: Final Fallback to execute_code_sandbox with PyMuPDF
Only attempt this if Steps 1-2 fail:
Tool: execute_code_sandbox
Language: python
Code: |
import fitz # PyMuPDF
try:
doc = fitz.open("document.pdf")
text = ""
for page in doc:
text += page.get_text()
doc.close()
with open("document_pymupdf.txt", "w") as f:
f.write(text)
print("SUCCESS: Extracted {} characters".format(len(text)))
except Exception as e:
print(f"FAILED: {e}")
Then read the result:
Tool: read_file
Path: document_pymupdf.txt
Step 4: Quality Verification
Regardless of which method succeeded, verify extraction quality:
- Check text length: Should be proportional to PDF pages (~500-2000 chars per page)
- Check readability: Text should form coherent sentences
- Check for truncation: Look for cut-off words or missing sections
- Compare methods: If multiple methods worked, compare outputs
If quality is poor:
- Try alternative extraction tools (pdfplumber, camelot-py for tables)
- Consider OCR for scanned documents
- Document limitations clearly
Step 5: Graceful Degradation to Domain Knowledge
If all extraction methods fail:
- Document the specific failure mode for each tool attempted
- Extract any partial content that was successfully retrieved
- Supplement missing content from established domain knowledge
- Clearly mark which portions are from source vs. generated from knowledge
- Provide citations for any claimed requirements or specifications
Example degradation note:
NOTE: Source document [path/URL] was inaccessible due to [specific tool failures].
Content below combines partial extraction with established domain knowledge
for [topic]. All claims verified against [alternative sources] where possible.
Tool Failure Log:
- read_file: Returned binary data (no text extraction)
- run_shell/pdftotext: Comman
Pertanyaan umum
Mengapa mulai dengan pembacaan sederhana?
Panduan ini menyatakan itu adalah percobaan tercepat, meskipun kadang mengembalikan data biner.
Mengapa pdftotext dicoba sebelum Python?
Panduan ini menemukan bahwa alat shell lebih andal di lingkungan yang terbatas.
Apakah kualitas teks diperiksa?
Ya, panduan ini menyertakan langkah untuk memverifikasi kualitas teks yang diekstrak.
Detail
Deskripsi asli dari pembuat
Progressive tool-chain PDF extraction with explicit read_file, run_shell, and execute_code_sandbox sequencing
repo: HKUDS/AgentPilot
Popularitas
- Bintang GitHub
- 7.8k
- Peringkat
- #12916
- Lisensi
- MIT
- Diperbarui
- 1/11/2026
Komentar
- …
Skill lain dari repositori ini
agentpilot
7.8kMembantu agent Anda meningkatkan proyek langkah demi langkah dengan menyiapkan tugas dan menjalankan loop AgentPilot yang mengusulkan, menguji, dan memberi skor pada perubahan.
openspace
7.8kMembantu agent Anda menyiapkan OpenSpace, alat yang menyimpan dan mengambil skill agent, lalu menghubungkannya ke aplikasi AI Anda melalui MCP.
rsi-arena
7.8kMembantu agent Anda menyiapkan dan menjalankan tes benchmark AI standar, seperti AIME dan Terminal-Bench, untuk membandingkan berbagai metode perbaikan.
experiment-guide
7.8kMembantu agent Anda merencanakan eksperimen kecil, membaca hasilnya, dan mencatat temuan saat menyelidiki cara memperbaiki sebuah program.
Skill serupa
feishu-doc
394kMembantu agent Anda membaca, membuat, dan mengedit dokumen cloud Feishu, termasuk teks, gambar, dan tabel, dengan memakai alat dokumen.
feishu-drive
394kMemungkinkan agent Anda menelusuri, mengatur, dan memberi komentar pada file di folder cloud Feishu yang sudah dibagikan kepada bot.
feishu-perm
394kMembantu agent Anda memeriksa dan mengubah siapa yang dapat mengakses file Feishu, dengan memilih izin terkecil yang memenuhi permintaan Anda.