pdflisted
Install: claude install-skill Davie521/claude-skills
# PDF Processing Guide
## Overview
This guide covers essential PDF processing operations using Python libraries and command-line tools. For advanced features, JavaScript libraries, and detailed examples, see reference.md. If you need to fill out a PDF form, read forms.md and follow its instructions.
## Environment Setup (do this first)
The bundled scripts and code examples require `pypdf` (plus `pdf2image` for PDF-to-image conversion and `pdfplumber` for form-structure extraction), which may not be installed on this machine. Install them into a virtual environment — in the project directory or your scratchpad directory. NEVER use `--break-system-packages`:
```bash
python3 -m venv .venv && source .venv/bin/activate && pip install pypdf pdf2image pdfplumber
```
Note: `pdf2image` also needs poppler at the system level (`brew install poppler` on macOS; check with `which pdftoppm`).
## Quick Start
```python
from pypdf import PdfReader, PdfWriter
# Read a PDF
reader = PdfReader("document.pdf")
print(f"Pages: {len(reader.pages)}")
# Extract text
text = ""
for page in reader.pages:
text += page.extract_text()
```
## Python Libraries
### pypdf - Basic Operations
#### Merge PDFs
```python
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)
```
####