pdf-page-verification-correctionlisted
Install: claude install-skill AG064/OpenSpace
# 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
Retu