본문으로 건너뛰기
cccskills
무료GitHub에 공개

pdf-verification-check-112b09

Check generated PDFs with PyPDF2, a Python library for reading PDF files. Verify that files exist, contain data, open successfully, and match expected page counts, then use failures to guide regeneration and another verification pass.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

Verify generated PDF files using PyPDF2 to check page counts and integrity

설치 방법 보기

이럴 때 유용합니다

  • Checking PDFs after generation
  • Verifying exact page count requirements
  • Validating multiple related PDF outputs
  • Rechecking PDFs after regeneration

포함된 파일(2)

  • SKILL.md3.4 KB
  • .skill_id43 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

PDF Verification Check

After generating PDF files, always programmatically verify their structure and integrity before declaring task completion. This catches formatting errors, incorrect page counts, and corrupted files early.

When to Use

Use this skill whenever your task involves:

  • Generating PDF documents
  • Creating PDFs with specific page count requirements
  • Producing multi-part PDF outputs (e.g., listings + maps)

Verification Steps

1. Install PyPDF2 (if not available)

pip install PyPDF2

2. Verify PDF Page Count and Integrity

Create a verification script or run inline Python:

from PyPDF2 import PdfReader
import os

def verify_pdf(pdf_path, expected_pages=None):
    """Verify PDF file exists, is readable, and has expected page count."""
    try:
        # Check file exists
        if not os.path.exists(pdf_path):
            return False, f"File not found: {pdf_path}"
        
        # Check file size (non-empty)
        file_size = os.path.getsize(pdf_path)
        if file_size == 0:
            return False, f"Empty file: {pdf_path}"
        
        # Open and verify PDF structure
        reader = PdfReader(pdf_path)
        actual_pages = len(reader.pages)
        
        # Check page count if expected
        if expected_pages is not None and actual_pages != expected_pages:
            return False, f"Expected {expected_pages} pages, got {actual_pages}"
        
        return True, f"Valid PDF with {actual_pages} page(s)"
        
    except Exception as e:
        return False, f"PDF verification failed: {str(e)}"

# Example usage
pdf_files = [
    ("listings.pdf", 2),
    ("map.pdf", 1),
]

all_valid = True
for pdf_path, expected in pdf_files:
    valid, message = verify_pdf(pdf_path, expected)
    print(f"{pdf_path}: {'✓' if valid else '✗'} {message}")
    if not valid:
        all_valid = False

if not all_valid:
    raise Exception("PDF verification failed - review and regenerate")

3. Use run_shell for Verification

Execute the verification using run_shell:

python -c "
from PyPDF2 import PdfReader
import sys

pdf_path = 'output.pdf'
expected = 2

try:
    reader = PdfReader(pdf_path)
    actual = len(reader.pages)
    if actual != expected:
        print(f'ERROR: Expected {expected} pages, got {actual}')
        sys.exit(1)
    print(f'OK: {pdf_path} has {actual} page(s)')
except Exception as e:
    print(f'ERROR: {e}')
    sys.exit(1)
"

4. Verify Before Completion

Critical: Only mark your task as complete after ALL PDF verification checks pass. If verification fails:

  1. Examine the error message
  2. Regenerate the PDF with corrected formatting
  3. Re-run verification
  4. Repeat until all checks pass

Common Issues Caught

  • Wrong page counts (e.g., content spilling to extra pages)
  • Empty or corrupted PDF files
  • PDFs that fail to open properly
  • Missing expected sections due to formatting errors

Example Workflow

# 1. Generate PDF
generate_pdf("listings.pdf", content)

# 2. Verify before completion
valid, msg = verify_pdf("listings.pdf", expected_pages=2)
if not valid:
    # Fix and regenerate
    regenerate_pdf("listings.pdf", corrected_content)
    valid, msg = verify_pdf("listings.pdf", expected_pages=2)

# 3. Only complete if verification passes
assert valid, f"Cannot complete: {msg}"

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Prepare audio stems, the separate parts of a track, for mixing by matching their durations with silence, loops, or crossfades. Verify each generated and processed file before moving to the next production step.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Match audio parts with different durations
  • Extend drums and melodic parts using suitable methods
  • Check audio specifications before mixing
HKUDS/OpenSpace7.8천2026년 8월 13일 업데이트

Produce audio in separate stems, meaning individual instrument tracks, and verify each output as you go. Align track lengths with silence, loops, or crossfades, then apply effects, mix a master, and package the files.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Align instrument tracks to a reference audio file
  • Choose how to extend tracks that are too short
  • Verify audio properties after generation and effects
HKUDS/OpenSpace7.8천2026년 8월 13일 업데이트

Build serverless endpoints that relay external API requests for a dashboard while keeping API keys on the server. Includes Vercel examples for input checks, caching, cross-origin access, and consistent JSON responses.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Connect a dashboard to external APIs without exposing API keys
  • Create endpoints for stock quotes and news
  • Standardize API responses and error handling
HKUDS/OpenSpace7.8천2026년 8월 13일 업데이트

Produce a master track and separate audio parts through a structured Python workflow. Apply filters and reverb, export WAV files with consistent settings, package them in a ZIP archive, and check that the deliverables meet the requested specifications.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Export a master track with separate audio parts
  • Apply filters and reverb to audio
  • Check duration and format across deliverables
HKUDS/OpenSpace7.8천2026년 8월 13일 업데이트

Keep document creation moving when web searches and page retrieval repeatedly fail. The skill preserves the original task, uses the model’s existing knowledge, and clearly identifies information that could not be checked against external sources.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Continue drafting after repeated web retrieval failures
  • Preserve task requirements during network errors
  • Mark information that could not be externally verified
HKUDS/OpenSpace7.8천2026년 8월 13일 업데이트

When Python execution repeatedly fails in execute_code_sandbox, use a file-based alternative: save the script, run it through the shell, and capture results or errors. The guidance covers paths, imports, timeouts, structured output, and optional cleanup.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Retry Python work through the shell after repeated sandbox failures
  • Run longer tasks with an adjusted timeout
  • Execute Python work that needs multiple files or system utilities
HKUDS/OpenSpace7.8천2026년 8월 13일 업데이트

HKUDS의 스킬 모두 보기

이 스킬의 문제 신고