Skill này làm gì
Skill này dạy agent cách làm việc với file PDF, như đọc văn bản, gộp hoặc tách file, và tạo file mới. Skill dành cho bất kỳ ai cần xử lý PDF mà không phải làm thủ công.
Khi nào nên dùng
- ✓Khi bạn tải lên một PDF và muốn lấy văn bản hoặc bảng ra khỏi nó.
- ✓Khi bạn muốn gộp, tách, xoay hoặc thêm watermark cho các trang PDF.
- ✓Khi bạn cần tạo một PDF mới hoặc điền một biểu mẫu PDF.
Liên kết skill
https://github.com/HKUDS/DeepTutor/blob/main/deeptutor/skills/builtin/pdf/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể lấy các bảng trong PDF này ra và đưa vào một danh sách cho tôi không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent dùng các công cụ Python sẵn có để đọc và thay đổi file PDF. Nó chạy việc xử lý trong một sandbox rồi trả về file đã hoàn thành.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Work PDFs in the sandbox with preinstalled Python libs. Pick the library by task:
- Extract text/tables/layout/word-coordinates →
pdfplumber; quick raw text or page ops →pypdf. - Merge / split / rotate / crop / watermark / encrypt / metadata →
pypdf. - Fill forms →
pypdf(fillable AcroForm fields) or annotation overlay (flat forms). - Create from scratch →
reportlab.
Use exec with complete Python source (language: python). Prefer creating,
reopening, and validating the PDF in one call; later calls can revise the same
relative filename. Follow the turn's User workspace instructions for
locating inputs, output boundaries, and presenting the finished file.
Preserve an explicitly requested quantity (such as 500 words) and verify the count in the output before finishing. If execution fails or the artifact is missing, diagnose stderr/root cause and change strategy; do not retry identical code or reduce the requested scope without asking.
Extract text and tables (pdfplumber)
import pdfplumber
with pdfplumber.open("in.pdf") as pdf:
for i, page in enumerate(pdf.pages, 1):
print(f"--- page {i} ---")
print(page.extract_text() or "") # layout-aware text
for t in page.extract_tables(): # list of tables; each is list[row]
for row in t:
print(row)
Tables → Excel (one worksheet per table):
import pdfplumber
from openpyxl import Workbook
workbook = Workbook()
workbook.remove(workbook.active)
table_number = 0
with pdfplumber.open("in.pdf") as pdf:
for page_number, page in enumerate(pdf.pages, 1):
for table in page.extract_tables():
if not table:
continue
table_number += 1
sheet = workbook.create_sheet(f"p{page_number}_table{table_number}"[:31])
for row in table:
sheet.append([cell or "" for cell in row])
if table_number:
workbook.save("tables.xlsx")
Messy tables: pass strategies, or crop a region with page.within_bbox((x0, top, x1, bottom)) first:
ts = {
"vertical_strategy": "lines",
"horizontal_strategy": "lines",
"snap_tolerance": 3,
"intersection_tolerance": 15,
}
page.extract_tables(ts)
For very large PDFs where you only need raw text, pypdf's page.extract_text() is lighter.
Scanned / image-only PDFs (be honest)
If extract_text() returns empty or garbage (e.g. (cid:NN) runs) the page is scanned. No OCR engine (tesseract) is installed and network is off, so you cannot recover that text. Say so plainly and stop — do not fabricate content or attempt pip install.
Merge / split / rotate / crop / metadata (pypdf)
from pypdf import PdfReader, PdfWriter
# Merge
w = PdfWriter()
for f in ["a.pdf", "b.pdf"]:
for p in PdfReader(f).pages:
w.add_page(p)
w.write("merged.pdf")
# Split: one file per page
r = PdfReader("in.pdf")
for i, p in enumerate(r.pages, 1):
w = PdfWriter()
w.add_page(p)
w.write(f"page_{i}.pdf")
# Rotate page 0 by 90 degrees clockwise
r = PdfReader("in.pdf")
w = PdfWriter()
r.pages[0].rotate(90)
w.add_page(r.pages[0])
w.write("rotated.pdf")
- Metadata:
PdfReader("in.pdf").metadata(.title,.author, ...). - Crop: set
page.mediabox.left/bottom/right/top(points, origin y=0 at bottom). - Encrypt:
w = PdfWriter(clone_from=PdfReader("in.pdf")); w.encrypt("userpw", "ownerpw"); w.write("enc.pdf"). - Decrypt:
r = PdfReader("enc.pdf"); r.decrypt("pw")ifr.is_encrypted, then read/copy pages.
Watermark (stamp one page over every page):
from pypdf import PdfReader, PdfWriter
wm = PdfReader("stamp.pdf").pages[0]
r = PdfReader("in.pdf")
w = PdfWriter()
for p in r.pages:
p.merge_page(wm)
w.add_page(p)
w.write("stamped.pdf")
Create PDFs (reportlab)
Flowing document (preferred for text/reports/tables — handles pagination):
from reportlab.lib.pagesizes import letter
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib import colors
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle
styles = getSampleStyleSheet()
story = [
Paragraph("Report Title", styles["Title"]),
Spacer(1, 12),
Paragraph("Body text. " * 20, styles["Normal"]),
]
data = [["Product", "Q1", "Q2"], ["Widgets", "120", "135"]]
tbl = Table(data)
tbl.setStyle(
TableStyle(
[
("BACKGROUND", (0, 0), (
Câu hỏi thường gặp
Nó có đọc được PDF scan không?
Skill không đề cập đến OCR cho PDF scan, nên các trang scan có thể không ra được văn bản.
Nó có điền được biểu mẫu PDF không?
Có. Nó có thể điền các trường biểu mẫu trong PDF, và có thể dùng lớp phủ cho biểu mẫu phẳng không có trường.
Nó có đặt mật khẩu cho PDF được không?
Có. Skill bao quát mã hóa và giải mã PDF, cùng watermark và metadata.
Chi tiết
Mô tả gốc của tác giả
Read, extract (text/tables), create, merge/split/rotate, watermark, encrypt, fill, and render-to-image .pdf files. Use whenever the user uploads a .pdf or asks to produce, edit, or pull data out of one.
repo: HKUDS/DeepTutor
Độ phổ biến
- Sao GitHub
- 54k
- Vị trí xếp hạng
- #3369
- Giấy phép
- Apache-2.0
- Cập nhật
- 31/10/2026
Bình luận
- …
Thêm skill từ kho mã này
deeptutor-cli
54kGiúp agent của bạn thiết lập và chạy DeepTutor, một nền tảng học tập, qua dòng lệnh, gồm knowledge base, sổ tay và ứng dụng web.
docx
54kGiúp agent của bạn đọc, tạo và chỉnh sửa file Word .docx, gồm báo cáo, bảng, tìm và thay thế, cùng các thay đổi được theo dõi kèm bình luận.
pptx
54kGiúp agent của bạn tạo, đọc và chỉnh sửa bộ slide PowerPoint, gồm văn bản slide, ghi chú người thuyết trình, biểu đồ và hình ảnh.
skill-creator
54kDạy agent của bạn viết hoặc cải thiện các skill DeepTutor, những gói hướng dẫn ngắn giúp AI nắm một tác vụ cụ thể.
Skill tương tự
feishu-doc
394kGiúp agent của bạn đọc, tạo và sửa tài liệu đám mây Feishu, gồm văn bản, hình ảnh và bảng, bằng công cụ tài liệu.
feishu-drive
394kCho phép agent của bạn duyệt, sắp xếp và bình luận các file trong một thư mục đám mây Feishu đã được chia sẻ với bot.
feishu-perm
394kGiúp agent của bạn kiểm tra và thay đổi ai có quyền truy cập một file Feishu, chọn quyền nhỏ nhất đáp ứng yêu cầu của bạn.