Pdf Page Verification Correction logo

Pdf Page Verification Correction

OrganizationPopular
HKUDS
pdf-page-verification-correction

Iterative workflow to verify PDF page counts and adjust layout parameters until requirements are met

Overview

PublisherHKUDS
RepositoryOpenSpace
Skill namepdf-page-verification-correction
Stars
7.8K
Forks
923
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by HKUDS on GitHub. Read the source before you install it.

Installation

Install the Pdf Page Verification Correction AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/HKUDS/OpenSpace/tree/main/benchmarks/gdpval/skills/pdf-page-verification-correction
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HKUDS/OpenSpace.git /tmp/OpenSpace
mkdir -p .claude/skills
cp -r /tmp/OpenSpace/benchmarks/gdpval/skills/pdf-page-verification-correction .claude/skills/pdf-page-verification-correction
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Pdf Page Verification Correction in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Pdf Page Verification Correction on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Pdf Page Verification Correction is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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:

python
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:

python
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

python
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:

python
# 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

python
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 converge
    return {
        'success': False,
        'final_page_count': page_count,
        'iterations': max_iterations,
        'final_params': params,
        'error': f"Failed to meet page requirement after {max_iterations} iterations"
    }

Example Usage

python
# Initial parameters
params = {
    'image_scale': 1.0,
    'font_size': 10,
    'margin_inches': 0.5,
    'rows_per_page': 15
}

# Create map PDF limited to 1 page
result = create_pdf_with_validation(
    output_path='property_map.pdf',
    initial_params=params,
    target_max_pages=1,
    max_iterations=5
)

if not result['success']:
    # Consider more aggressive adjustments or content reduction
    print(f"Warning: {result['error']}")

Tips

  1. Prioritize adjustments: Start with less intrusive changes (margins, image scale) before more significant ones (font size, content removal)

  2. Track iteration history: Log each iteration's parameters and page count to identify which adjustments are most effective

  3. Set reasonable limits: Don't reduce parameters below readable/viewable thresholds

  4. Consider content-based solutions: If layout adjustments fail, consider removing or summarizing content

  5. Use multiple strategies sequentially: Try image reduction first, then table density, then fonts

Common Adjustment Order

  1. Reduce margins (least visible impact)
  2. Reduce image sizes
  3. Reduce table density / increase pagination
  4. Reduce font sizes
  5. Remove or summarize content (last resort)

Frequently asked questions

What does the Pdf Page Verification Correction AI skill do?

Iterative workflow to verify PDF page counts and adjust layout parameters until requirements are met

Why use Pdf Page Verification Correction on TypingMind?

Because you install it once and use it with any model. Pdf Page Verification Correction is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Pdf Page Verification Correction in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/HKUDS/OpenSpace/tree/main/benchmarks/gdpval/skills/pdf-page-verification-correction. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Pdf Page Verification Correction?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Pdf Page Verification Correction?

As many as you like. As long as a model supports skills, you can use Pdf Page Verification Correction with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Pdf Page Verification Correction AI skill free?

Yes. It is published on GitHub by HKUDS under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇