Skip to main content
skill CX Codex

pdf · shareai-lab — Claude Code skill: read, create and merge PDF files

This skill hands your agent ready recipes for pulling text out of PDFs, building documents from Markdown, and merging files. Useful whenever a PDF shows up in the task.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add shareAI-lab/learn-claude-code --skill pdf -a claude-code
Open on GitHub

What pdf does

The skill covers five operations: reading, creating, merging, splitting into pages, and reading metadata. Text extraction goes through pdftotext from poppler-utils, with a PyMuPDF fallback in python3 when that binary is missing. Creation has three routes: pandoc from Markdown, ReportLab from code, and wkhtmltopdf or pdfkit from HTML.

Merging and splitting run on PyMuPDF. You open each source document, insert it into a fresh one, and save. Page-by-page processing is there for large files so memory does not blow up. Encoding gets a mention too, since PDFs carry different character sets and an empty extraction result does not always mean the page is blank.

Check that the tools exist before you lean on them: pdftotext comes from poppler, while PyMuPDF, ReportLab and pdfkit install through pip. For scanned documents the skill points at pytesseract when plain extraction returns nothing. That is worth deciding up front, because a text PDF and a scan need different dependencies.

What it helps with

  • pull text out of a PDF from the terminal
  • build a PDF from a Markdown file
  • merge several PDFs into one document
  • split a PDF into single pages
  • inspect page count and metadata

Example prompts for the agent

  • Extract the text from report.pdf and print all of it
  • Build output.pdf from notes.md with pandoc
  • Merge file1.pdf, file2.pdf and file3.pdf into merged.pdf

How to install pdf

1Skills CLI (Vercel)

npx skills add shareAI-lab/learn-claude-code --skill pdf -a claude-code

2Manually: put the files in place

~/.claude/skills/pdf/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/pdf/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about pdf

How do I install the pdf skill in Claude?

Run npx skills add shareAI-lab/learn-claude-code --skill pdf -a claude-code. The skill lands at ~/.claude/skills/pdf/SKILL.md.

What does the pdf skill do?

It gives the agent working recipes for PDFs: extracting text, creating documents from Markdown, HTML or code, merging files and splitting them by page.

What do I need installed for it to work?

The skill tells you to verify your tools first. Text extraction uses pdftotext from poppler or PyMuPDF, creation uses ReportLab, pdfkit with wkhtmltopdf, or pandoc, and scans call for pytesseract.

Source text

SKILL.md · MIT
---
name: pdf
description: Process PDF files - extract text, create PDFs, merge documents. Use when user asks to read PDF, create PDF, or work with PDF files.
---

# PDF Processing Skill

You now have expertise in PDF manipulation. Follow these workflows:

## Reading PDFs

**Option 1: Quick text extraction (preferred)**
```bash
# Using pdftotext (poppler-utils)
pdftotext input.pdf -  # Output to stdout
pdftotext input.pdf output.txt  # Output to file

# If pdftotext not available, try:
python3 -c "
import fitz  # PyMuPDF
doc = fitz.open('input.pdf')
for page in doc:
    print(page.get_text())
"
```

**Option 2: Page-by-page with metadata**
```python
import fitz  # pip install pymupdf

doc = fitz.open("input.pdf")
print(f"Pages: {len(doc)}")
print(f"Metadata: {doc.metadata}")

for i, page in enumerate(doc):
    text = page.get_text()
    print(f"--- Page {i+1} ---")
    print(text)
```

## Creating PDFs

**Option 1: From Markdown (recommended)**
```bash
# Using pandoc
pandoc input.md -o output.pdf

# With custom styling
pandoc input.md -o output.pdf --pdf-engine=xelatex -V geometry:margin=1in
```

**Option 2: Programmatically**
```python
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

c = canvas.Canvas("output.pdf", pagesize=letter)
c.drawString(100, 750, "Hello, PDF!")
c.save()
```

**Option 3: From HTML**
```bash
# Using wkhtmltopdf
wkhtmltopdf input.html output.pdf

# Or with Python
python3 -c "
import pdfkit
pdfkit.from_file('input.html', 'output.pdf')
"
```

## Merging PDFs

```python
import fitz

result = fitz.open()
for pdf_path in ["file1.pdf", "file2.pdf", "file3.pdf"]:
    doc = fitz.open(pdf_path)
    result.insert_pdf(doc)
result.save("merged.pdf")
```

## Splitting PDFs

```python
import fitz

doc = fitz.open("input.pdf")
for i in range(len(doc)):
    single = fitz.open()
    single.insert_pdf(doc, from_page=i, to_page=i)
    single.save(f"page_{i+1}.pdf")
```

## Key Libraries

| Task | Library | Install |
|------|---------|---------|
| Read/Write/Merge | PyMuPDF | `pip install pymupdf` |
| Create from scratch | ReportLab | `pip install reportlab` |
| HTML to PDF | pdfkit | `pip install pdfkit` + wkhtmltopdf |
| Text extraction | pdftotext | `brew install poppler` / `apt install poppler-utils` |

## Best Practices

1. **Always check if tools are installed** before using them
2. **Handle encoding issues** - PDFs may contain various character encodings
3. **Large PDFs**: Process page by page to avoid memory issues
4. **OCR for scanned PDFs**: Use `pytesseract` if text extraction returns empty

© shareAI-lab · MIT · shareAI-lab/learn-claude-code

Similar skills

Everything for Office documents →

pdf by other authors comes first.

pdf official anthropics This skill lets an agent read, create, and edit PDF files, including forms and scanned documents. Use it when PDF work is part of the task. 216,041installs pdf official openai A skill for reading, creating and reviewing PDFs where layout matters. Useful when the agent builds a document and needs to see how it renders. CX Codex +1 13,400installs pdf nexu-io Extracts text, creates PDF documents, and fills out forms. Helps produce press releases, branded one-pagers, and printable design deliverables. CX Codex +1 3,000installs pdf-to-html daymade Turns a PDF into one self-contained HTML file that keeps images, tables and reading order. Handy when you want to read a report on your phone instead of scrolling pages. CX Codex +1 458installs convert-pdf-to-md official github Turns PDF files into Markdown text and extracts embedded images. Helps GitHub Copilot inspect documents, tables, and reports without manual copy-pasting. 138installs pdf-generation glebis Turns markdown into a finished PDF with Pandoc and the Eisvogel template: title page, table of contents, colour-coded themes. Built for reports and docs. CX Codex +1 482installs geo-report-pdf geo-seo-claude Turns a GEO audit markdown report into a PDF with a cover page, color-coded score tables, and a 90-day roadmap. Uses pandoc and Chrome headless. CX Codex +1 833installs business-document-generator ailabs-393 Turns your data into a PDF proposal, business plan or annual budget by filling a ready template with a Python script. CX Codex +1 1,400installs doc openai A skill for reading, creating and editing .docx files when layout matters — tables, page breaks, fonts. Useful when the document goes to a client. 99installs

From the same set3

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor