pdf-page-verification-correction
Skill này làm gì
Skill này kiểm tra PDF đã tạo có bao nhiêu trang và thay đổi bố cục cho đến khi khớp mục tiêu. Dành cho người cần báo cáo, bản tóm tắt hoặc bản đồ có số trang cố định.
Khi nào nên dùng
- ✓Khi một PDF phải đúng số trang, chẳng hạn bản tóm tắt một trang.
- ✓Khi hình ảnh, bảng hoặc văn bản dài khiến số trang khó dự đoán.
- ✓Khi PDF đầu tiên quá dài hoặc quá ngắn.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-page-verification-correction/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 tóm tắt PDF của tôi phải đúng hai trang. Hãy kiểm tra số trang và điều chỉnh bố cục cho đến khi đúng.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI tạo PDF, đếm số trang bằng một thư viện PDF, so sánh với mục tiêu, và thay đổi các thiết lập như cỡ chữ hoặc lề trước khi thử lại.
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.
PDF Page Count Verification and Correction
This skill provides a systematic approach to ensure PDFs meet target page count requirements through iterative verification and layout adjustment.
When to Use
- Creating PDFs with strict page limits (e.g., reports, summaries, maps)
- When initial PDF generation may produce variable page counts
- When layout elements (images, tables, text) can cause unpredictable overflow
Prerequisites
- Python with PyPDF2 or fitz (PyMuPDF) installed
- PDF generation capability (ReportLab, matplotlib, etc.)
Workflow Steps
Step 1: Initial PDF Creation
Generate the PDF with your initial layout parameters:
def create_pdf(output_path, params):
"""Create PDF with given layout parameters"""
# Your PDF generation logic here
# params can include: image_size, table_density, font_size, margins
pass
Step 2: Verify Page Count
Check the generated PDF's page count:
import fitz # PyMuPDF
def verify_page_count(pdf_path):
"""Return the number of pages in the PDF"""
doc = fitz.open(pdf_path)
page_count = len(doc)
doc.close()
return page_count
# Alternative with PyPDF2
from PyPDF2 import PdfReader
def verify_page_count_pypdf2(pdf_path):
reader = PdfReader(pdf_path)
return len(reader.pages)
Step 3: Compare Against Target
def check_page_requirement(actual, target_max, target_exact=None):
"""
Check if page count meets requirements
Returns: (meets_requirement, adjustment_needed)
"""
if target_exact is not None:
meets = (actual == target_exact)
direction = "shrink" if actual > target_exact else "expand" if actual < target_exact else None
else:
meets = (actual <= target_max)
direction = "shrink" if actual > target_max else None
return meets, direction
Step 4: Adjust Layout Parameters
If page count exceeds target, adjust one or more parameters:
# Common adjustment strategies
ADJUSTMENT_STRATEGIES = {
'images': {
'action': 'reduce_size',
'param': 'image_scale',
'step': 0.1, # Reduce by 10%
'min': 0.5
},
'tables': {
'action': 'reduce_density',
'param': 'rows_per_page',
'step': 2, # Reduce by 2 rows per page
'min': 5
},
'fonts': {
'action': 'reduce_size',
'param': 'font_size',
'step': 1, # Reduce by 1pt
'min': 8
},
'margins': {
'action': 'reduce',
'param': 'margin_inches',
'step': 0.1, # Reduce by 0.1 inches
'min': 0.3
}
}
def adjust_params(current_params, direction, strategy='images'):
"""Apply adjustment to parameters"""
adjusted = current_params.copy()
strat = ADJUSTMENT_STRATEGIES[strategy]
if direction == 'shrink':
param = strat['param']
current_val = adjusted.get(param, 1.0)
new_val = max(current_val - strat['step'], strat['min'])
adjusted[param] = new_val
return adjusted
Step 5: Iterative Correction Loop
def create_pdf_with_validation(
output_path,
initial_params,
target_max_pages,
max_iterations=5
):
"""
Create PDF with iterative page count verification and correction
Args:
output_path: Where to save the final PDF
initial_params: Starting layout parameters
target_max_pages: Maximum allowed pages
max_iterations: Maximum adjustment attempts
Returns:
dict with 'success', 'final_page_count', 'iterations', 'final_params'
"""
params = initial_params.copy()
for iteration in range(max_iterations):
# Create PDF
create_pdf(output_path, params)
# Verify
page_count = verify_page_count(output_path)
# Check requirements
meets_req, direction = check_page_requirement(
page_count, target_max_pages
)
if meets_req:
print(f"✓ PDF created successfully: {page_count} pages")
return {
'success': True,
'final_page_count': page_count,
'iterations': iteration + 1,
'final_params': params
}
# Adjust and retry
print(f"Iteration {iteration + 1}: {page_count} pages (need ≤{target_max_pages})")
params = adjust_params(params, direction)
# Failed to conver
Câu hỏi thường gặp
Những phần nào của bố cục có thể thay đổi?
Hướng dẫn liệt kê kích thước hình ảnh, mật độ bảng, cỡ chữ và lề.
Số trang được kiểm tra thế nào?
Bằng PyMuPDF hoặc PyPDF2, các thư viện này cho biết tệp có bao nhiêu trang.
Có lặp lại quy trình không?
Có. Nó lặp lại kiểm tra và điều chỉnh cho đến khi đáp ứng yêu cầu.
Chi tiết
Mô tả gốc của tác giả
Iterative workflow to verify PDF page counts and adjust layout parameters until requirements are met
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #12930
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentpilot
7.8kGiúp agent của bạn cải thiện dự án từng bước bằng cách chuẩn bị tác vụ và chạy vòng lặp AgentPilot, gồm đề xuất, kiểm thử và chấm điểm thay đổi.
openspace
7.8kGiúp agent của bạn thiết lập OpenSpace, công cụ lưu và lấy lại skill của agent, rồi kết nối nó với ứng dụng AI của bạn qua MCP.
rsi-arena
7.8kGiúp agent của bạn thiết lập và chạy các bài kiểm thử benchmark AI chuẩn, như AIME và Terminal-Bench, để so sánh các phương pháp cải tiến khác nhau.
experiment-guide
7.8kGiúp agent của bạn lên kế hoạch các thí nghiệm nhỏ, đọc kết quả và ghi lại phát hiện khi tìm cách cải thiện một chương trình.
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.