मुख्य सामग्री पर जाएँ
Skillpedia
PDF, Word और स्लाइड7.8k · #12936

pdf-verification-check-112b09

यह क्या करती है

यह स्किल पक्का करती है कि AI की बनाई PDF मौजूद है, खाली नहीं है और उसमें सही संख्या में पेज हैं। यह उन लोगों के लिए है जिन्हें इस्तेमाल से पहले PDF फ़ाइलों पर भरोसा चाहिए।

कब इस्तेमाल करें

  • ✓जब काम में PDF बनी हो और खत्म करने से पहले उसकी जाँच होनी हो।
  • ✓जब PDF में कोई खास पेज संख्या चाहिए।
  • ✓जब काम में कई PDF आउटपुट बनें और सबकी जाँच ज़रूरी हो।

Skill का लिंक

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-verification-check-112b09/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-verification-check-112b09/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“PDF बनाने के बाद जाँचिए कि फ़ाइल मौजूद है, खाली नहीं है, और उसमें ठीक तीन पेज हैं।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

AI ज़रूरत पड़ने पर PyPDF2 इंस्टॉल करता है, एक छोटा Python फ़ंक्शन चलाता है जो पुष्टि करता है कि फ़ाइल मौजूद है, उसमें सामग्री है और अपेक्षित पेज संख्या से मेल खाती है, और नतीजा बताता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

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}"
अक्सर पूछे जाने वाले सवाल

जाँच क्या पक्का करती है?

कि फ़ाइल मौजूद है, खाली नहीं है, और अपेक्षित पेज संख्या के साथ खोली जा सकती है।

PyPDF2 किस काम आता है?

यह PDF खोलता है और उसके पेज गिनता है।

अगर गिनती गलत हो तो?

जाँच अंतर बताती है, ताकि AI बनाने के चरण को ठीक कर सके।

जानकारी

लेखक का मूल विवरण

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

repo: HKUDS/AgentPilot

लोकप्रियता

GitHub स्टार
7.8k
रैंकिंग में स्थान
#12936
लाइसेंस
MIT
अपडेट की गई
1/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills