pdf-verification-cli
What it does
This skill shows how to verify PDFs with standard command line tools. It is for people in minimal environments who need to confirm a PDF's page count and content.
When to use it
- ✓When I need to confirm how many pages a PDF has.
- ✓When I need to check what text a PDF actually contains.
- ✓When PyPDF2 or similar Python libraries are not available.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-verification-cli/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Check how many pages this PDF has and confirm the text is what I expect. Python PDF libraries are not installed here.”
5 new skills a week. 1 minute to read.
How it works
The AI runs pdfinfo to get the page count and metadata, then runs pdftotext to view the content, using layout options when needed.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
PDF Verification with Command-Line Tools
When verifying PDF files during task execution, Python libraries like PyPDF2 may not be available in the environment. This skill provides a reliable alternative using standard command-line tools from the poppler-utils package.
When to Use This Skill
- Need to verify PDF page count
- Need to inspect PDF text content
- PyPDF2 or similar Python PDF libraries are unavailable
- Working in minimal/containerized environments
Core Tools
1. pdfinfo - Extract PDF Metadata
Use pdfinfo to get page count and other metadata:
# Get full PDF info
pdfinfo document.pdf
# Get only page count
pdfinfo document.pdf | grep Pages
# Extract page count as a number
pdfinfo document.pdf | grep Pages | awk '{print $2}'
Key metadata fields:
Pages: Number of pages in the PDFTitle: Document titleAuthor: Document authorCreator: Application that created the PDFProducer: Application that processed the PDFCreationDate: When the PDF was createdModDate: Last modification date
2. pdftotext - Extract Text Content
Use pdftotext to inspect the actual content of the PDF:
# Extract all text to stdout
pdftotext document.pdf -
# Extract text to a file
pdftotext document.pdf output.txt
# Extract text from specific page range
pdftotext -f 1 -l 3 document.pdf output.txt
# Preserve layout (rough formatting)
pdftotext -layout document.pdf output.txt
Verification Workflow
Step 1: Check Tool Availability
# Check if tools are installed
which pdfinfo
which pdftotext
# Or test with --help
pdfinfo --help 2>&1 | head -1
Step 2: Install if Needed
# Debian/Ubuntu
apt-get update && apt-get install -y poppler-utils
# RHEL/CentOS/Fedora
yum install -y poppler-utils
# or
dnf install -y poppler-utils
# macOS (with Homebrew)
brew install poppler
Step 3: Verify PDF Properties
# Verify page count matches expected
EXPECTED_PAGES=4
ACTUAL_PAGES=$(pdfinfo document.pdf | grep Pages | awk '{print $2}')
if [ "$ACTUAL_PAGES" -eq "$EXPECTED_PAGES" ]; then
echo "✓ Page count verified: $ACTUAL_PAGES pages"
else
echo "✗ Page count mismatch: expected $EXPECTED_PAGES, got $ACTUAL_PAGES"
fi
Step 4: Verify PDF Content
# Check for required sections/content
pdftotext document.pdf - | grep -i "checklist" && echo "✓ Contains checklist section"
pdftotext document.pdf - | grep -i "references" && echo "✓ Contains references section"
# Count occurrences of key terms
pdftotext document.pdf - | grep -ci "assessment" # Case-insensitive count
Python Integration Example
import subprocess
def get_pdf_page_count(pdf_path):
"""Get page count using pdfinfo"""
result = subprocess.run(
['pdfinfo', pdf_path],
capture_output=True,
text=True
)
for line in result.stdout.split('\n'):
if line.startswith('Pages:'):
return int(line.split(':')[1].strip())
return None
def extract_pdf_text(pdf_path):
"""Extract all text from PDF using pdftotext"""
result = subprocess.run(
['pdftotext', pdf_path, '-'],
capture_output=True,
text=True
)
return result.stdout
def verify_pdf(pdf_path, expected_pages, required_terms):
"""Verify PDF has expected page count and contains required terms"""
# Check page count
pages = get_pdf_page_count(pdf_path)
if pages != expected_pages:
return False, f"Expected {expected_pages} pages, got {pages}"
# Check content
text = extract_pdf_text(pdf_path).lower()
missing = [term for term in required_terms if term.lower() not in text]
if missing:
return False, f"Missing terms: {missing}"
return True, "PDF verification passed"
Common Use Cases
| Task | Command |
|---|---|
| Count pages | pdfinfo file.pdf | grep Pages |
| Check if PDF has text | pdftotext file.pdf - | head -5 |
| Search for keyword | pdftotext file.pdf - | grep -i "keyword" |
| Extract first page | pdftotext -f 1 -l 1 file.pdf out.txt |
| Get PDF title | pdfinfo file.pdf | grep Title |
Troubleshooting
pdfinfo: command not found
- Install poppler-utils (see Step 2 above)
- Ensure PATH includes the installation directory
pdftotext returns empty output
- PDF may be image-only (scanned) - requires OCR
- PDF may be encrypted/password-protected
- Try
pdftotext -layoutfor better text ext
FAQ
What does pdfinfo return?
Metadata such as Pages, Title, Author and the creation date.
How is only the page count printed?
The guide pipes pdfinfo output through grep and awk to get the number.
Can the text be saved to a file?
Yes, pdftotext can write the text to a file.
Details
Original description by the author
Verify PDF page count and content using command-line tools when Python libraries unavailable
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #12940
- License
- MIT
- Updated
- 11/1/2026
Comments
- …
More skills from this repository
agentpilot
7.8kHelps your agent improve a project step by step by preparing a task and running the AgentPilot loop that proposes, tests and scores changes.
openspace
7.8kHelps your agent set up OpenSpace, a tool that stores and fetches agent skills, and connect it to your AI app through MCP.
rsi-arena
7.8kHelps your agent set up and run standard AI benchmark tests, such as AIME and Terminal-Bench, to compare different improvement methods.
experiment-guide
7.8kHelps your agent plan small experiments, read their results and record findings while it investigates how to improve a program.
Similar skills
feishu-doc
394kHelps your agent read, create, and edit Feishu cloud documents, including text, images, and tables, using the document tool.
feishu-drive
394kLets your agent browse, organize, and comment on files in a Feishu cloud folder that has been shared with the bot.
feishu-perm
394kHelps your agent check and change who can access a Feishu file, choosing the smallest permission that meets your request.