pypdf splits, merges, crops, and transforms PDF pages, and can extract text, metadata, images, and attachments.
Overview
pypdf is a pure-Python library for working with PDF documents. You can split and merge files, crop or transform pages, add passwords and viewer options, and read or write document metadata and text.
The user guide covers encryption and decryption, form handling, outlines, annotations, stamps and watermarks, JavaScript in PDFs, streaming IO, size reduction, and PDF/A topics. Reader and writer classes share common document operations, with guidance on strict parsing behavior and security-related warnings.
Optional extra dependencies unlock AES encryption and decryption when installing the crypto extra. For command-line workflows, the separate pdfly tool builds on pypdf to interact with PDFs from a terminal.
Developers pick pypdf when they need programmatic PDF manipulation without tying their project to a heavyweight native stack, staying entirely in Python for parsing and generation tasks.
Key features
- Split, merge, crop, and transform pages
- Text and metadata extraction
- Encryption and decryption support
- Annotations and form field handling
- Image and attachment extraction
- Merge and watermark utilities
- Streaming read and write
- Pure Python implementation
Use cases
- Automated PDF assembly in Python
- Extracting text or metadata from reports
- Securing documents with passwords
- Batch page cropping or rotation
- Building PDF tooling on top of pdfly