pdf-analyzer
FreeNo executable scriptsNot checkedExtract text, tables, metadata, and structured data from PDF files. Use when a user asks to read a PDF, parse a PDF, extract data from a PDF, summarize a PDF…
by TerminalSkills★ 221 GitHub starsAbout this skill
PDF Analyzer
Overview
Extract text, tables, and structured data from PDF files and convert them into usable formats. This skill handles text extraction, table detection, metadata reading, and output formatting for single or multi-page PDFs.
Instructions
When a user asks you to analyze, read, parse, or extract data from a PDF file, follow these steps:
Step 1: Identify the PDF and goal
Determine the file path and what the user wants extracted:
- Full text: All readable text from every page
- Tables: Structured tabular data
- Metadata: Title, author, creation date, page count
- Specific sections: Targeted content from certain pages
- Summary: A condensed version of the document contents
Step 2: Choose the extraction method
Write a Python script using pdfplumber (prefer it for tables) or PyMuPDF (import pymupdf; the old fitz name is deprecated and only warns). Pass password= for encrypted files; pdfplumber raises an empty PdfminerException otherwise.
For text extraction:
import pdfplumber
def extract_text(pdf_path, password=None):
text_by_page = []
with pdfplumber.open(pdf_path, password=password) as pdf:
for i, page in enumerate(pdf.pages):
text = page.extract_text()
if text:
text_by_page.append({"page": i + 1, "text": text.strip()})
return text_by_page
For table extraction:
import pdfplumber
import csv
# Default "lines" strategy needs ruling lines. For borderless tables
# pass the "text" strategy. It returns empty spacer rows (filtered below) and can
# take a title line above the table as the first row, so check the headers.
TEXT_STRATEGY = {"vertical_strategy": "text", "horizontal_strategy": "text"}
def extract_tables(pdf_path, output_csv=None, password=None, text_strategy=False):
all_tables = []
settings = TEXT_STRATEGY if text_strategy else None
with pdfplumber.open(pdf_path, password=password) as pdf:
for i, page in enumerate(pdf.pages):
tables = page.extract_tables(settings) if settings else page.extract_tables()
for table in tables:
headers = table[0]
rows = [r for r in table[1:] if any(c for c in r)]
all_tables.append({
"page": i + 1,
"headers": headers,
"rows": rows
})
if output_csv and all_tables:
with open(output_csv, "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(all_tables[0]["headers"])
for table in all_tables:
writer.writerows(table["rows"])
return all_tables
For metadata:
import pdfplumber
def extract_metadata(pdf_path):
with pdfplumber.open(pdf_path) as pdf:
return {
"pages": len(pdf.pages),
"metadata": pdf.metadata
}
Step 3: Run the script and format output
Execute the script, then present results in the format the user needs (plain text, JSON, CSV, markdown table, or summary).
Step 4: Handle errors gracefully
If extraction fails or comes back empty, check these cases in order:
- Encrypted:
pdfplumber.openraisesPdfminerExceptionwith no message. Ask the user for the password and retry withpassword=.... Never guess passwords. - Scanned: a page whose
extract_text()returns nothing but whosepage.imagesis non-empty needs OCR. Tesseract is a system binary, sopip install pytesseractalone is not enough. OCR with PyMuPDF, which needs the Tesseract binary and language data:import pymupdf doc = pymupdf.open(pdf_path) page = doc[0] # keep the page in a variable: the text page holds a weak reference to it tp = page.get_textpage_ocr(language="eng", dpi=300, full=True) text = page.get_text(textpage=tp) - Borderless tables: the default pdfplumber strategy returns no tables. Retry with
text_strategy=True. - Broken parser: switch from pdfplumber to PyMuPDF (
import pymupdf), then report which library produced the output.
Examples
Example 1: Extract all tables from an invoice PDF
User request: "Pull the line items table from invoice.pdf and save as CSV"
Actions taken:
- Open
invoice.pdfwith pdfplumber - Detect tables on each page
- Extract headers and rows
- Write to
invoice_items.csv
Output:
Found 1 table on page 1 with 5 columns: Item, Quantity, Unit Price, Tax, Total
Extracted 12 rows. Saved to invoice_items.csv.
Preview:
| Item | Quantity | Unit Price | Tax | Total |
|-----------------|----------|------------|-------|---------|
| Widget A | 100 | $2.50 | $25.00| $275.00 |
| Widget B | 50 | $4.00 | $20.00| $220.00 |
Example 2: Summarize a research paper
User request: "Summarize the key findings from paper.pdf"
Actions taken:
- Extract full text from
Install pdf-analyzer in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the pdf-analyzer skill do?
Extract text, tables, metadata, and structured data from PDF files. Use when a user asks to read a PDF, parse a PDF, extract data from a PDF, summarize a PDF document, pull tables from a PDF, or convert PDF content to structured formats like JSON or CSV. Handles single and multi-page documents, flags scanned PDFs for OCR, and reads borderless and password-protected PDFs.
How do I install the pdf-analyzer skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the pdf-analyzer skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
by AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
by Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
by Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
by Anthropic