# PDF Reader and Editor

Reads, extracts, creates, merges, splits, fills and renders PDF files.

- Repository: https://github.com/HKUDS/DeepTutor (53613 stars)
- Category: Documents
- License: Apache-2.0
- Last updated: 2026-10-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add HKUDS/DeepTutor --skill pdf -g -a claude-code -y`
Codex: `npx skills add HKUDS/DeepTutor --skill pdf -g -a codex -y`
Cursor: `npx skills add HKUDS/DeepTutor --skill pdf -g -a cursor -y`
Gemini CLI: `npx skills add HKUDS/DeepTutor --skill pdf -g -a gemini-cli -y`

## Description

Read, extract (text/tables), create, merge/split/rotate, watermark, encrypt, fill, and render-to-image .pdf files. Use whenever the user uploads a .pdf or asks to produce, edit, or pull data out of one.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# PDF

Work PDFs in the sandbox with preinstalled Python libs. Pick the library by task:

- **Extract** text/tables/layout/word-coordinates → `pdfplumber`; quick raw text or page ops → `pypdf`.
- **Merge / split / rotate / crop / watermark / encrypt / metadata** → `pypdf`.
- **Fill forms** → `pypdf` (fillable AcroForm fields) or annotation overlay (flat forms).
- **Create from scratch** → `reportlab`.

Use `exec` with complete Python source (`language: python`). Prefer creating,
reopening, and validating the PDF in one call; later calls can revise the same
relative filename. Follow the turn's **User workspace** instructions for
locating inputs, output boundaries, and presenting the finished file.
Preserve an explicitly requested quantity (such as 500 words) and verify the count in the output before finishing. If execution fails or the artifact is missing, diagnose stderr/root cause and change strategy; do not retry identical code or reduce the requested scope without asking.

## Extract text and tables (pdfplumber)

```python
import pdfplumber

with pdfplumber.open("in.pdf") as pdf:
    for i, page in enumerate(pdf.pages, 1):
        print(f"--- page {i} ---")
        print(page.extract_text() or "")  # layout-aware text
        for t in page.extract_tables():  # list of tables; each is list[row]
            for row in t:
                print(row)
```

Tables → Excel (one worksheet per table):
```python
import pdfplumber
from openpyxl import Workbook

workbook = Workbook()
workbook.remove(workbook.active)
table_number = 0
with pdfplumber.open("in.pdf") as pdf:
    for page_number, page in enumerate(pdf.pages, 1):
        for table in page.extract_tables():
            if not table:
                continue
            table_number += 1
            sheet = workbook.create_sheet(f"p{page_number}_table{table_number}"[:31])
            for row in table:
                sheet.append([cell or "" for cell in row])
if table_number:
    workbook.save("tables.xlsx")
```

The rest: https://github.com/HKUDS/DeepTutor/blob/HEAD/deeptutor/skills/builtin/pdf/SKILL.md
