| name | document-processing |
| description | 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
with 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)
if 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)
with open("merged.pdf", "wb") as output:
writer.write(output)
Split PDF
from pypdf import PdfReader, PdfWriter
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)
Rotate Pages
from pypdf import PdfReader, PdfWriter
reader = PdfReader("input.pdf")
writer = PdfWriter()
page = reader.pages[0]
page.rotate(90)
writer.add_page(page)
with open("rotated.pdf", "wb") as output:
writer.write(output)
OCR Scanned PDFs
import pytesseract
from pdf2image import convert_from_path
images = convert_from_path('scanned.pdf')
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
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)
with open("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")
with open("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 = []
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())
story.append(Paragraph("Page 2", styles['Heading1']))
story.append(Paragraph("Content for page 2", styles['Normal']))
doc.build(story)
Command Line Tools
pdftotext input.pdf output.txt
pdftotext -layout input.pdf output.txt
qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf
qpdf input.pdf --pages . 1-5 -- pages1-5.pdf
qpdf input.pdf output.pdf --rotate=+90:1
qpdf --password=mypassword --decrypt encrypted.pdf decrypted.pdf
pdfimages -j input.pdf output_prefix
Word Document (DOCX) Processing
Text Extraction
pandoc document.docx -o output.md
pandoc --track-changes=all document.docx -o output.md
Create New Document (docx-js)
import { Document, Paragraph, TextRun, HeadingLevel, Packer } from 'docx';
import * as fs from 'fs';
const doc = new Document({
sections: [{
properties: {},
children: [
new Paragraph({
text: "Document Title",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph({
children: [
new TextRun("This is a "),
new TextRun({
text: "bold",
bold: true,
}),
new TextRun(" word in a paragraph."),
],
}),
new Paragraph({
text: "This is another paragraph.",
}),
],
}],
});
const buffer = await Packer.toBuffer(doc);
fs.writeFileSync(, buffer);
Create Document with Tables
import { Document, Paragraph, Table, TableRow, TableCell, Packer } from 'docx';
const table = new Table({
rows: [
new TableRow({
children: [
new TableCell({ children: [new Paragraph("Header 1")] }),
new TableCell({ children: [new Paragraph("Header 2")] }),
new TableCell({ children: [new Paragraph("Header 3")] }),
],
}),
new TableRow({
children: [
new TableCell({ children: [new Paragraph("Cell 1")] }),
new TableCell({ children: [new Paragraph("Cell 2")] }),
new TableCell({ children: [new ()] }),
],
}),
],
});
doc = ({
: [{
: [
({ : , : . }),
table,
],
}],
});
Edit Existing Document (OOXML)
For complex edits, work with raw OOXML:
-
Unpack the document:
python ooxml/scripts/unpack.py document.docx unpacked/
-
Edit XML files (primarily word/document.xml)
-
Validate and pack:
python ooxml/scripts/validate.py unpacked/ --original document.docx
python ooxml/scripts/pack.py unpacked/ output.docx
Tracked Changes Workflow
For document review with track changes:
pandoc --track-changes=all document.docx -o current.md
python ooxml/scripts/unpack.py document.docx unpacked/
python ooxml/scripts/pack.py unpacked/ reviewed.docx
PowerPoint (PPTX) Processing
Text Extraction
python -m markitdown presentation.pptx
Create New Presentation (PptxGenJS)
import PptxGenJS from 'pptxgenjs';
const pptx = new PptxGenJS();
const slide1 = pptx.addSlide();
slide1.addText("Presentation Title", {
x: 1, y: 2, w: 8, h: 1.5,
fontSize: 36,
bold: true,
color: "363636",
align: "center",
});
slide1.addText("Subtitle goes here", {
x: 1, y: 3.5, w: 8, h: 0.5,
fontSize: 18,
color: "666666",
align: "center",
});
const slide2 = pptx.addSlide();
slide2.addText("Key Points", {
x: 0.5, y: 0.5, w: 9, h: ,
: ,
: ,
});
slide2.([
{ : , : { : } },
{ : , : { : } },
{ : , : { : } },
], {
: , : , : , : ,
: ,
});
slide3 = pptx.();
slide3.(pptx.., [
{ : , : [, , ], : [, , ] },
{ : , : [, , ], : [, , ] },
], {
: , : , : , : ,
: ,
: ,
});
pptx.();
Edit Existing Presentation (OOXML)
python ooxml/scripts/unpack.py presentation.pptx unpacked/
python ooxml/scripts/validate.py unpacked/ --original presentation.pptx
python ooxml/scripts/pack.py unpacked/ output.pptx
Create Thumbnail Grid
python scripts/thumbnail.py presentation.pptx --cols 4
Convert Slides to Images
soffice --headless --convert-to pdf presentation.pptx
pdftoppm -jpeg -r 150 presentation.pdf slide
Excel (XLSX) Processing
Data Analysis with Pandas
import pandas as pd
df = pd.read_excel('file.xlsx')
all_sheets = pd.read_excel('file.xlsx', sheet_name=None)
df.head()
df.info()
df.describe()
filtered = df[df['Sales'] > 1000]
grouped = df.groupby('Category')['Revenue'].sum()
df.to_excel('output.xlsx', index=False)
Create Excel with Formulas (openpyxl)
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Alignment
wb = Workbook()
sheet = wb.active
sheet['A1'] = 'Product'
sheet['B1'] = 'Price'
sheet['C1'] = 'Quantity'
sheet['D1'] = 'Total'
for cell in ['A1', 'B1', 'C1', 'D1']:
sheet[cell].font = Font(bold=True, color='FFFFFF')
sheet[cell].fill = PatternFill('solid', start_color='4472C4')
sheet[cell].alignment = Alignment(horizontal='center')
data = [
('Widget A', 10.00, 5),
('Widget B', 15.00, 3),
('Widget C', 20.00, 8),
]
for row_idx, (product, price, qty) in enumerate(data, start=2):
sheet[f'A{row_idx}'] = product
sheet[f'B{row_idx}'] = price
sheet[f'C{row_idx}'] = qty
sheet[f'D{row_idx}'] = f'=B{row_idx}*C'
last_row = (data) +
sheet[] =
sheet.column_dimensions[].width =
sheet.column_dimensions[].width =
sheet.column_dimensions[].width =
sheet.column_dimensions[].width =
wb.save()
Financial Model Standards
Color Coding
from openpyxl.styles import Font
BLUE = Font(color='0000FF')
BLACK = Font(color='000000')
GREEN = Font(color='008000')
RED = Font(color='FF0000')
sheet['B5'].font = BLUE
sheet['B6'].font = BLACK
Number Formatting
sheet['B5'].number_format = '$#,##0'
sheet['B6'].number_format = '0.0%'
sheet['B7'].number_format = '$#,##0;($#,##0);"-"'
sheet['B8'].number_format = '0.0x'
CRITICAL: Use Formulas, Not Hardcoded Values
total = df['Sales'].sum()
sheet['B10'] = total
sheet['B10'] = '=SUM(B2:B9)'
growth = (current - previous) / previous
sheet['C5'] = growth
sheet['C5'] = '=(C4-C2)/C2'
Edit Existing Excel
from openpyxl import load_workbook
wb = load_workbook('existing.xlsx')
sheet = wb.active
sheet['A1'] = 'New Value'
sheet.insert_rows(2)
sheet.delete_cols(3)
new_sheet = wb.create_sheet('Analysis')
new_sheet['A1'] = 'Data'
wb.save('modified.xlsx')
Recalculate Formulas
After creating/modifying Excel files with formulas:
python recalc.py output.xlsx
Dependencies
Install as needed:
pip install pypdf pdfplumber reportlab pytesseract pdf2image
npm install -g docx
pip install "markitdown[docx]"
npm install -g pptxgenjs
pip install "markitdown[pptx]"
pip install pandas openpyxl
sudo apt-get install poppler-utils qpdf libreoffice pandoc
Quick Task Reference
| I want to... | Command/Code |
|---|
| Extract PDF text | pdfplumber.open(f).pages[0].extract_text() |
| Merge PDFs | pypdf.PdfWriter() + loop |
| Split PDF | One PdfWriter() per page |
| OCR scanned PDF | pdf2image → pytesseract |
| Convert DOCX to MD | pandoc doc.docx -o doc.md |
| Create DOCX | docx-js (JavaScript) |
| Extract PPTX text | python -m markitdown pres.pptx |
| Create PPTX | PptxGenJS (JavaScript) |
| Analyze Excel | pandas.read_excel() |
| Excel with formulas | openpyxl |
Credits & Attribution
This skill is based on the excellent work by
Anthropic.
Original repository: https://github.com/anthropics/skills/tree/main/skills/document-processing
Special thanks to Anthropic for their generous open-source contributions, which helped shape this skill collection.
Adapted by webconsulting.at for this skill collection