P

pdf-official

Verified

by sickn33 · Updated Apr 16, 2026

opus
18in5.1Kout
$0.502m 11s

This guide covers essential PDF processing operations using Python libraries and command-line tools. For advanced features, JavaScript libraries, and detailed examples, see reference.md. If you need to fill out a PDF form, read forms.md and follow its instructions.

pdfpythondocument-processingtext-extractionocrreport-generation

See It In Action

1 turns·claude
The project codebase is in your current working directory. Explore the files to understand the code before making changes. got 3 partner quarterly revenue pdfs for the board today — pull all the revenue tables together and include text extracts we can audit

Let me start by finding the PDF files and understanding the project structure.

Found the 3 PDFs. Let me read them all and the skill guide to determine the best extraction approach.

I have all three PDFs. Let me use pdfplumber to programmatically extract the tables and text, then consolidate everything into a single report with audit-ready extracts.

Let me install the dependencies and run extraction.

Python venv mismatch — pip installed to conda's 3.13 but the active python is a 3.12 venv. Let me install into the correct environment.

Text extraction worked perfectly on all 3 (including the scanned Q3). The tables are text-formatted (not PDF table objects), so pdfplumber's table detector found 0 structured tables. I'll parse the revenue lines from the extracted text instead.

All 3 PDFs extracted cleanly. Here's the summary for the board:


Acme Corporation - Q1-Q3 2025 Revenue Consolidated

Quarterly Totals (all sum checks passed)

QuarterRevenueYoYQoQ
Q1 2025$4,540,000+14.2%--
Q2 2025$5,130,000+16.8%+13.0%
Q3 2025$5,720,000+18.5%+11.5%
YTD$15,390,000

By Category (YTD)

  • Enterprise Software: $8.3M (54.0%) -- largest segment
  • Cloud Services: $5.0M (32.2%) -- fastest YoY growth (22-37%)
  • Professional Services: $2.1M (13.8%)

By Region (YTD)

  • North America: $7.7M (49.8%)
  • EMEA: $4.8M (31.1%)
  • APAC: $2.9M (19.1%) -- highest growth rates across all categories

Key board notes from reports

  • Q3 was a record quarter driven by enterprise renewals + cloud expansion
  • APAC Cloud Services growth at +37.1% is the standout segment
  • Board approved FY2026 EMEA investment plan
  • Q3 report was scanned from a printed copy (text extracted cleanly)

Audit artifacts

  • consolidated_revenue.csv -- all 27 line items with source file traceability
  • Full text extracts from all 3 PDFs printed above for audit comparison
  • Integrity checks: all 3 quarterly sums match reported totals exactly
Claude Sonnet 4.6

External Tools

ToolType
python3binary
pipbinary

Permissions

ScopeDescription
filesystem:read
filesystem:write
process:spawn

SKILL.md

PDF Processing Guide

Overview

This guide covers essential PDF processing operations using Python libraries and command-line tools. For advanced features, JavaScript libraries, and detailed examples, see reference.md. If you need to fill out a PDF form, read forms.md and follow its instructions.

Quick Start

from pypdf import PdfReader, PdfWriter

# Read a PDF
reader = PdfReader("document.pdf")
print(f"Pages: {len(reader.pages)}")

# Extract text
text = ""
for page in reader.pages:
    text += page.extract_text()

Python Libraries

pypdf - Basic Operations

Merge PDFs

from pypdf import PdfWriter, PdfReader

writer = PdfWriter()
for pdf_file in ["doc1.pdf", "doc2.pdf", "doc3.pdf"]:
    reader = PdfReader(pdf_file)
    for page in reader.pages:
        writer.add_page(page)

with open("merged.pdf", "wb") as output:
    writer.write(output)

Split PDF

reader = PdfReader("input.pdf")
for i, page in enumerate(reader.pages):
    writer = PdfWriter()
    writer.add_page(page)
    with open(f"page_{i+1}.pdf", "wb") as output:
        writer.write(output)

Extract Metadata

reader = PdfReader("document.pdf")
meta = reader.metadata
print(f"Title: {meta.title}")
print(f"Author: {meta.author}")
print(f"Subject: {meta.subject}")
print(f"Creator: {meta.creator}")

Rotate Pages

reader = PdfReader("input.pdf")
writer = PdfWriter()

page = reader.pages[0]
page.rotate(90)  # Rotate 90 degrees clockwise
writer.add_page(page)

with open("rotated.pdf", "wb") as output:
    writer.write(output)

pdfplumber - Text and Table Extraction

Extract Text with Layout

import pdfplumber

with pdfplumber.open("document.pdf") as pdf:
    for page in pdf.pages:
        text = page.extract_text()
        print(text)

Extract Tables

with pdfplumber.open("document.pdf") as pdf:
    for i, page in enumerate(pdf.pages):
        tables = page.extract_tables()
        for j, table in enumerate(tables):
            print(f"Table {j+1} on page {i+1}:")
            for row in table:
                print(row)

Advanced Table Extraction

import pandas as pd

with pdfplumber.open("document.pdf") as pdf:
    all_tables = []
    for page in pdf.pages:
        tables = page.extract_tables()
        for table in tables:
            if table:  # Check if table is not empty
                df = pd.DataFrame(table[1:], columns=table[0])
                all_tables.append(df)

# Combine all tables
if all_tables:
    combined_df = pd.concat(all_tables, ignore_index=True)
    combined_df.to_excel("extracted_tables.xlsx", index=False)

reportlab - Create PDFs

Basic PDF Creation

from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

c = canvas.Canvas("hello.pdf", pagesize=letter)
width, height = letter

# Add text
c.drawString(100, height - 100, "Hello World!")
c.drawString(100, height - 120, "This is a PDF created with reportlab")

# Add a line
c.line(100, height - 140, 400, height - 140)

# Save
c.save()

Create PDF with Multiple Pages

from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak
from reportlab.lib.styles import getSampleStyleSheet

doc = SimpleDocTemplate("report.pdf", pagesize=letter)
styles = getSampleStyleSheet()
story = []

# Add content
title = Paragraph("Report Title", styles['Title'])
story.append(title)
story.append(Spacer(1, 12))

body = Paragraph("This is the body of the report. " * 20, styles['Normal'])
story.append(body)
story.append(PageBreak())

# Page 2
story.append(Paragraph("Page 2", styles['Heading1']))
story.append(Paragraph("Content for page 2", styles['Normal']))

# Build PDF
doc.build(story)

Command-Line Tools

pdftotext (poppler-utils)

# Extract text
pdftotext input.pdf output.txt

# Extract text preserving layout
pdftotext -layout input.pdf output.txt

# Extract specific pages
pdftotext -f 1 -l 5 input.pdf output.txt  # Pages 1-5

qpdf

# Merge PDFs
qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf

# Split pages
qpdf input.pdf --pages . 1-5 -- pages1-5.pdf
qpdf input.pdf --pages . 6-10 -- pages6-10.pdf

# Rotate pages
qpdf input.pdf output.pdf --rotate=+90:1  # Rotate page 1 by 90 degrees

# Remove password
qpdf --password=mypassword --decrypt encrypted.pdf decrypted.pdf

pdftk (if available)

# Merge
pdftk file1.pdf file2.pdf cat output merged.pdf

# Split
pdftk input.pdf burst

# Rotate
pdftk input.pdf rotate 1east output rotated.pdf

Common Tasks

Extract Text from Scanned PDFs

# Requires: pip install pytesseract pdf2image
import pytesseract
from pdf2image import convert_from_path

# Convert PDF to images
images = convert_from_path('scanned.pdf')

# OCR each page
text = ""
for i, image in enumerate(images):
    text += f"Page {i+1}:\n"
    text += pytesseract.image_to_string(image)
    text += "\n\n"

print(text)

Add Watermark

from pypdf import PdfReader, PdfWriter

# Create watermark (or load existing)
watermark = PdfReader("watermark.pdf").pages[0]

# Apply to all pages
reader = PdfReader("document.pdf")
writer = PdfWriter()

for page in reader.pages:
    page.merge_page(watermark)
    writer.add_page(page)

with open("watermarked.pdf", "wb") as output:
    writer.write(output)

Extract Images

# Using pdfimages (poppler-utils)
pdfimages -j input.pdf output_prefix

# This extracts all images as output_prefix-000.jpg, output_prefix-001.jpg, etc.

Password Protection

from pypdf import PdfReader, PdfWriter

reader = PdfReader("input.pdf")
writer = PdfWriter()

for page in reader.pages:
    writer.add_page(page)

# Add password
writer.encrypt("userpassword", "ownerpassword")

with open("encrypted.pdf", "wb") as output:
    writer.write(output)

Quick Reference

TaskBest ToolCommand/Code
Merge PDFspypdfwriter.add_page(page)
Split PDFspypdfOne page per file
Extract textpdfplumberpage.extract_text()
Extract tablespdfplumberpage.extract_tables()
Create PDFsreportlabCanvas or Platypus
Command line mergeqpdfqpdf --empty --pages ...
OCR scanned PDFspytesseractConvert to image first
Fill PDF formspdf-lib or pypdf (see forms.md)See forms.md

Next Steps

  • For advanced pypdfium2 usage, see reference.md
  • For JavaScript libraries (pdf-lib), see reference.md
  • If you need to fill out a PDF form, follow the instructions in forms.md
  • For troubleshooting guides, see reference.md

When to Use

This skill is applicable to execute the workflow or actions described in the overview.

FAQ

What does pdf-official do?

This guide covers essential PDF processing operations using Python libraries and command-line tools. For advanced features, JavaScript libraries, and detailed examples, see reference.md. If you need to fill out a PDF form, read forms.md and follow its instructions.

When should I use pdf-official?

Use it when you need a repeatable workflow that produces structured table, source code.

What does pdf-official output?

In the evaluated run it produced structured table, source code.

How do I install or invoke pdf-official?

Ask the agent to use this skill when the task matches its documented workflow.

Which agents does pdf-official support?

Agent support is inferred from the source, but not explicitly declared.

What tools, channels, or permissions does pdf-official need?

It uses python3, pip; channels commonly include table, code; permissions include filesystem:read, filesystem:write, process:spawn.

Is pdf-official safe to install?

Static analysis marked this skill as medium risk; review side effects and permissions before enabling it.

How is pdf-official different from an MCP or plugin?

A skill packages instructions and workflow conventions; tools, MCP servers, and plugins are dependencies the skill may call during execution.

Does pdf-official outperform not using a skill?

About pdf-official

When to use pdf-official

When you need to merge, split, rotate, encrypt, or watermark PDF files programmatically. When you need to extract text or tables from PDF documents into local files for analysis. When you need to generate simple reports or PDFs from code.

When pdf-official is not the right choice

When the task requires a cloud connector or external document platform integration. When you only need general guidance about PDFs without actually running Python-based processing.

What it produces

Produces structured table and source code.