pdf-page-verification-correction
できること
このスキルは、生成されたPDFのページ数を確認し、目標に一致するまでレイアウトを変えます。決まったページ数のレポート、要約、地図などが必要な人向けです。
使う場面
- ✓1ページの要約のように、PDFが正確なページ数に収まる必要があるとき。
- ✓画像、表、長いテキストのせいで、ページ数を予測しにくいとき。
- ✓最初のPDFが長すぎる、または短すぎたとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-page-verification-correction/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“要約のPDFはちょうど2ページである必要があります。ページ数を確認して、合うようにレイアウトを調整してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIはPDFを作り、PDFライブラリでページ数を数え、目標と比べて、フォントサイズや余白などの設定を変えてから、もう一度試します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
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
よくある質問
レイアウトのどの部分が変えられますか?
画像のサイズ、表の詰まり具合、フォントのサイズ、余白をガイドは挙げています。
ページ数はどう確認しますか?
PyMuPDFまたはPyPDF2で、ファイルが何ページあるかを報告させて確認します。
この作業は繰り返されますか?
はい。要件が満たされるまで、確認と調整を繰り返します。
詳細
作者による元の説明
Iterative workflow to verify PDF page counts and adjust layout parameters until requirements are met
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #12930
- ライセンス
- MIT
- 更新日
- 2026/11/1
コメント
- …
このリポジトリの他のスキル
agentpilot
7.8kエージェントが、作業を準備し、変更案を提案してテストし、評価するAgentPilotのループを実行することで、プロジェクトを段階的に改善できるよう支援します。
openspace
7.8kエージェントが、スキルを保存し取り出すツールであるOpenSpaceをセットアップし、MCPを通じてAIアプリに接続できるよう支援します。
rsi-arena
7.8kエージェントが、AIMEやTerminal-Benchなどの標準的なAIベンチマークテストをセットアップして実行し、異なる改善方法を比較できるよう支援します。
experiment-guide
7.8kエージェントが、プログラムを改善する方法を調べる間に、小さな実験を計画し、その結果を読み、発見を記録できるよう支援します。
似ているスキル
feishu-doc
394kテキスト、画像、表を含むFeishuのクラウドドキュメントを、ドキュメントツールを使って読み、作成し、編集するようエージェントを支援します。
feishu-drive
394kボットと共有されたFeishuのクラウドフォルダ内のファイルを閲覧、整理、コメントできるようエージェントを支援します。
feishu-perm
394kFeishuのファイルにアクセスできる人を確認し、変更するようエージェントを支援します。依頼を満たす最小の権限を選びます。