一键导入
Use when working with PDF files — reading, extracting text or tables, merging, splitting, or filling forms. Provides correct library choices and common patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when working with PDF files — reading, extracting text or tables, merging, splitting, or filling forms. Provides correct library choices and common patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when building a new agent harness, designing tool systems, or structuring multi-agent workflows. Provides patterns, templates, and decision trees for harness engineering.
Use when asked to review code, audit a file for bugs, check code quality, or suggest improvements. Provides a structured review process and issue categorisation.
| name | |
| description | Use when working with PDF files — reading, extracting text or tables, merging, splitting, or filling forms. Provides correct library choices and common patterns. |
Load when the user asks you to:
Need to extract text from a normal (not scanned) PDF?
→ pdfplumber (best text + table extraction)
Need to manipulate pages (merge, split, rotate)?
→ pypdf (formerly PyPDF2)
Need to fill form fields?
→ pypdf with writer.update_page_form_field_values()
PDF is scanned (images of pages, no selectable text)?
→ pytesseract + pdf2image (OCR pipeline)
Need to create a PDF from scratch?
→ reportlab or fpdf2
pip install pdfplumber pypdf
# For OCR:
pip install pytesseract pdf2image
# Also requires: tesseract-ocr (system package) and poppler-utils
import pdfplumber
with pdfplumber.open("document.pdf") as pdf:
for page in pdf.pages:
text = page.extract_text()
if text:
print(text)
import pdfplumber
with pdfplumber.open("document.pdf") as pdf:
for page in pdf.pages:
tables = page.extract_tables()
for table in tables:
for row in table:
print(row)
from pypdf import PdfWriter
writer = PdfWriter()
for filename in ["part1.pdf", "part2.pdf", "part3.pdf"]:
writer.append(filename)
with open("merged.pdf", "wb") as f:
writer.write(f)
from pypdf import PdfReader, PdfWriter
reader = PdfReader("document.pdf")
for i, page in enumerate(reader.pages):
writer = PdfWriter()
writer.add_page(page)
with open(f"page_{i+1}.pdf", "wb") as f:
writer.write(f)
from pypdf import PdfReader, PdfWriter
reader = PdfReader("document.pdf")
writer = PdfWriter()
for page_num in [0, 2, 4]: # 0-indexed
writer.add_page(reader.pages[page_num])
with open("selected.pdf", "wb") as f:
writer.write(f)
Text comes back garbled or empty The PDF may use a non-standard encoding or be scanned. Try OCR:
# pip install pdf2image pytesseract
from pdf2image import convert_from_path
import pytesseract
images = convert_from_path("scanned.pdf")
for img in images:
print(pytesseract.image_to_string(img))
Tables not extracting correctly Try adjusting the extraction strategy:
page.extract_table(table_settings={"vertical_strategy": "lines",
"horizontal_strategy": "lines"})
Large PDF crashes memory Process page by page, don't load entire PDF into memory:
with pdfplumber.open("large.pdf") as pdf:
for page in pdf.pages:
process(page.extract_text()) # one page at a time