debug-pdf-extraction
Debug PDF text extraction issues. Use when parser is producing wrong data, missing units, or garbled text from a PDF.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Debug PDF Extraction
PDFs store visual layout, not logical text structure. This causes extraction issues like merged columns, wrong reading order, and corrupted characters.
Inspect Raw Page Text
Create a temporary script to see exactly what pdfplumber extracts:
# parser/debug_pdf.py
import pdfplumber
with pdfplumber.open("/path/to/SomeGame.pdf") as pdf:
page = pdf.pages[PAGE_NUMBER - 1] # 0-indexed
text = page.extract_text()
for j, line in enumerate(text.split("\n")):
print(f"{j:3}: {repr(line)}")
Run with:
cd parser && uv run python debug_pdf.py
Common Issues
Merged columns
Text from sidebars gets concatenated with main content:
"sCenario 10: marChinG to CoLd harbor 4. Destroyed RR Stations: The following..."
Solution: Use regex to extract just the part you need.
Weird capitalization
Small caps fonts appear as mixed case:
"sCenario" instead of "Scenario"
Solution: Use case-insensitive matching (re.IGNORECASE).
Table extraction issues
Tables may not parse correctly with extract_text(). Try:
tables = page.extract_tables()
for table in tables:
for row in table:
print(row)
Inspect Specific Elements
# Find text containing a pattern
import re
for i, page in enumerate(pdf.pages):
text = page.extract_text() or ""
if re.search(r"pattern", text, re.IGNORECASE):
print(f"Found on page {i+1}")
Clean Up
Delete parser/debug_pdf.py when done—it's just for investigation.
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!