Create, edit, and analyze office documents (PDF, DOCX, PPTX, XLSX). Use when working with PDFs, Word documents, PowerPoint presentations, or Excel spreadsheets. Covers text extraction, form filling, document creation, and data analysis.
Create, edit, and analyze office documents (PDF, DOCX, PPTX, XLSX). Use when working with PDFs, Word documents, PowerPoint presentations, or Excel spreadsheets. Covers text extraction, form filling, document creation, and data analysis.
license
Source-available (see github.com/anthropics/skills)
metadata
{"version":"1.0.0"}
Document Processing
Source: This skill is adapted from Anthropic's document-processing skill
document processing skills (pdf, docx, pptx, xlsx) for Claude Code and AI agents.
Create, edit, and analyze office documents including PDFs, Word documents, PowerPoint presentations,
and Excel spreadsheets.
Quick Reference: Which Tool to Use
Task
Document Type
Best Tool
Extract text
PDF
pdfplumber, pdftotext
Merge/split
PDF
pypdf, qpdf
Fill forms
PDF
pdf-lib (JS), pypdf
Create new
PDF
reportlab
OCR scanned
PDF
pytesseract + pdf2image
Extract text
DOCX
pandoc, markitdown
Create new
DOCX
docx-js (JS)
Edit existing
DOCX
OOXML (unpack/edit/pack)
Extract text
PPTX
markitdown
Create new
PPTX
html2pptx, PptxGenJS
Edit existing
PPTX
OOXML (unpack/edit/pack)
Data analysis
XLSX
pandas
Formulas/formatting
XLSX
openpyxl
PDF Processing
Text Extraction
import pdfplumber
# Extract text with layout preservationwith pdfplumber.open("document.pdf") as pdf:
for page in pdf.pages:
text = page.extract_text()
print(text)
Table Extraction
import pdfplumber
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:
df = pd.DataFrame(table[1:], columns=table[0])
all_tables.append(df)
# Combine all tablesif all_tables:
combined_df = pd.concat(all_tables, ignore_index=True)
combined_df.to_excel("extracted_tables.xlsx", index=False)
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)
withopen("merged.pdf", "wb") as output:
writer.write(output)
Split PDF
from pypdf import PdfReader, PdfWriter
reader = PdfReader("input.pdf")
for i, page inenumerate(reader.pages):
writer = PdfWriter()
writer.add_page(page)
withopen(f"page_{i+1}.pdf", "wb") as output:
writer.write(output)
# Requires: pip install pytesseract pdf2imageimport pytesseract
from pdf2image import convert_from_path
# Convert PDF to images
images = convert_from_path('scanned.pdf')
# OCR each page
text = ""for i, image inenumerate(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
watermark = PdfReader("watermark.pdf").pages[0]
reader = PdfReader("document.pdf")
writer = PdfWriter()
for page in reader.pages:
page.merge_page(watermark)
writer.add_page(page)
withopen("watermarked.pdf", "wb") as output:
writer.write(output)
Password Protection
from pypdf import PdfReader, PdfWriter
reader = PdfReader("input.pdf")
writer = PdfWriter()
for page in reader.pages:
writer.add_page(page)
writer.encrypt("userpassword", "ownerpassword")
withopen("encrypted.pdf", "wb") as output:
writer.write(output)
Create PDF with ReportLab
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']))
doc.build(story)
# 1. Get current state
pandoc --track-changes=all document.docx -o current.md
# 2. Unpack
python ooxml/scripts/unpack.py document.docx unpacked/
# 3. Edit using tracked change patterns# Use <w:ins> for insertions, <w:del> for deletions# 4. Pack final document
python ooxml/scripts/pack.py unpacked/ reviewed.docx
# Create visual overview of all slides
python scripts/thumbnail.py presentation.pptx --cols 4
Convert Slides to Images
# Convert to PDF first
soffice --headless --convert-to pdf presentation.pptx
# Then PDF to images
pdftoppm -jpeg -r 150 presentation.pdf slide
# Creates slide-1.jpg, slide-2.jpg, etc.
Excel (XLSX) Processing
Data Analysis with Pandas
import pandas as pd
# Read Excel
df = pd.read_excel('file.xlsx') # Default: first sheet
all_sheets = pd.read_excel('file.xlsx', sheet_name=None) # All sheets as dict# Analyze
df.head() # Preview data
df.info() # Column info
df.describe() # Statistics# Filter and transform
filtered = df[df['Sales'] > 1000]
grouped = df.groupby('Category')['Revenue'].sum()
# Write Excel
df.to_excel('output.xlsx', index=False)
from openpyxl.styles import Font
# Industry-standard colors
BLUE = Font(color='0000FF') # Hardcoded inputs
BLACK = Font(color='000000') # Formulas
GREEN = Font(color='008000') # Links from other sheets
RED = Font(color='FF0000') # External links# Apply to cells
sheet['B5'].font = BLUE # User input
sheet['B6'].font = BLACK # Formula
Number Formatting
# Currency with thousands separator
sheet['B5'].number_format = '$#,##0'# Percentage with one decimal
sheet['B6'].number_format = '0.0%'# Zeros as dashes
sheet['B7'].number_format = '$#,##0;($#,##0);"-"'# Multiples
sheet['B8'].number_format = '0.0x'
CRITICAL: Use Formulas, Not Hardcoded Values
# ❌ WRONG - Hardcoding calculated values
total = df['Sales'].sum()
sheet['B10'] = total # Hardcodes 5000# ✅ CORRECT - Use Excel formulas
sheet['B10'] = '=SUM(B2:B9)'# ❌ WRONG - Computing in Python
growth = (current - previous) / previous
sheet['C5'] = growth
# ✅ CORRECT - Excel formula
sheet['C5'] = '=(C4-C2)/C2'
Special thanks to Anthropic for their generous open-source contributions, which helped shape this skill collection.
Adapted by webconsulting.at for this skill collection