본문으로 건너뛰기
Skillpedia
PDF, Word, 슬라이드7.8k · #12930

pdf-page-verification-correction

하는 일

이 스킬은 생성된 PDF의 페이지 수를 확인하고 목표에 맞을 때까지 레이아웃을 바꿉니다. 고정된 쪽수의 보고서, 요약 또는 지도가 필요한 사람에게 맞습니다.

사용하는 경우

  • ✓한 페이지 요약처럼 정확한 쪽수에 맞춰야 하는 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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-page-verification-correction/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 요약 PDF는 정확히 두 쪽이어야 합니다. 쪽수를 확인하고 맞을 때까지 레이아웃을 조정해 주세요.”

매주 새 스킬 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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬