pypdf

A pure-Python library for splitting, merging, cropping, transforming, and extracting content from PDF files.

Library
PyPI
v6.16.2
10,177stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
94/100Excellent
Development Activity96
Maintenance96
Community84
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
86/100Excellent
Architecture85
Code Quality92
Innovation78
Learning Curve90

pypdf is a free, open-source, pure-Python library for working with PDF files. It can split, merge, crop, and transform pages, add passwords and viewing restrictions, extract text and metadata, and manipulate annotations, bookmarks, and form fields — all without any external binary dependencies like Poppler or MuPDF.

The library grew out of the original PyPDF2 project and has since become the de facto standard pure-Python PDF toolkit, with over 27 million weekly downloads on PyPI. It ships full type hints (mypy strict mode) and a test suite exercising real-world PDF files pulled from a companion sample-files repository, which has made it a dependency of choice for teams that need predictable, dependency-light PDF processing inside Python backends, data pipelines, and document-automation tools.

What You Get

  • PdfReader and PdfWriter classes for loading, creating, and saving PDF documents from files, bytes, or streams
  • Page-level operations: merge, split, rotate, crop, scale, and overlay/watermark pages via the Transformation API
  • Text and metadata extraction, including layout-aware extraction modes for tables and multi-column documents
  • Encryption and decryption support (standard and AES, with cryptography or PyCryptodome as optional backends)
  • Direct access to the low-level PDF object model (generic module) for advanced manipulation of dictionaries, streams, and cross-reference tables
  • Form field (AcroForm) reading and filling, annotation manipulation, and outline/bookmark management
  • Full static typing (py.typed, mypy strict) so downstream code gets accurate autocomplete and type checking

Common Use Cases

  • Merging or splitting multi-page PDF reports generated by other systems
  • Stripping or adding passwords and permissions to PDFs before distribution
  • Extracting text and structured metadata from PDFs for search indexing or document pipelines
  • Watermarking or stamping generated PDFs (e.g. invoices, contracts) with overlay pages
  • Filling and reading AcroForm fields in PDF-based forms as part of document-automation workflows

Under The Hood

Architecture pypdf splits into a high-level document API (PdfReader and PdfWriter, sharing common logic through a PdfDocCommon mixin) and a low-level PDF object model (dictionaries, arrays, streams, indirect references, cross-reference tables) that both classes operate on directly. Page-level logic (PageObject, Transformation) composes onto that object model rather than duplicating parsing, and stream filtering/decoding (compression, image formats) is isolated from encryption, which is fully separated with pluggable crypto backends. This layered design means most feature work touches the page or object-model layer without needing to change the reader/writer’s core parsing, though the object model is foundational enough that a breaking change there would ripple through nearly every module.

Tech Stack Pure Python 3.9+ with no mandatory runtime dependencies beyond a typing backport on older interpreters; optional extras (cryptography or PyCryptodome for AES, Pillow for image extraction, fonttools, arabic-reshaper/python-bidi for right-to-left text) are declared as pip extras so consumers only install what they use. The build backend is flit_core with packaging metadata centralized in pyproject.toml, and documentation is built with Sphinx and hosted on Read the Docs.

Code Quality The test suite is extensive and runs with network access disabled by default, with tests opting into network or “real-world sample” access via explicit markers backed by a companion sample-files repository. CI runs the suite across multiple operating systems and Python versions (including PyPy) with parallelized test execution and coverage upload, plus a dedicated strict-mode type-check pass. Linting is configured to select the full rule set of its linter with an explicit, reasoned set of exceptions rather than a loose default configuration. Combined with full static typing throughout the package, this is a rigorously tooled codebase relative to typical pure-language libraries in its category.

API Design The public surface is deliberately small — only a handful of top-level classes and helpers are exported, keeping a much larger implementation mostly hidden behind two entry points. Getting started requires almost no boilerplate: loading a file and extracting text from its first page is a one-liner. The reader and writer share behavior through a common mixin so both feel consistent, and advanced users can drop into the low-level object model when the high-level API doesn’t cover a case, though that layer demands more familiarity with the PDF specification itself. Errors are raised as a typed hierarchy rather than generic exceptions, which aids programmatic handling upstream.

Used by 23 apps in this directory

Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,969

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python100%
Updated today
Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,645

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
65
Dependency
Built with
Python90%
Updated today
Python
67%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,997

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
67
Dependency
Built with
Python67%
TypeScript31%
Updated today
Rust
52%
Apache 2.0

cocoindex

Data Engineering · AI Development

11,431

An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.

View details
86
Repo Health
85
Technical
64
Dependency
Built with
Rust52%
Python48%
Updated 2 days ago
Python
67%
Apache 2.0

GPT Researcher

Productivity · AI Assistants

29,203

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
91
Repo Health
91
Technical
64
Dependency
Built with
Python67%
TypeScript20%
Updated 3 days ago
Python
100%
MIT

Graphify

AI Agents

112,429

A YC-backed, open-source knowledge graph skill for AI coding assistants — type /graphify and it maps your entire project (code, docs, PDFs, images, videos) into a queryable graph instead of grepping through files.

View details
83
Repo Health
73
Technical
73
Dependency
Built with
Python100%
Updated yesterday
HTML
47%
LGPL-2.1

Horilla

Human Resources · ERP

1,346

Open-source HRMS covering recruitment, attendance, payroll, and biometrics in one self-hosted Django application.

View details
88
Repo Health
60
Technical
65
Dependency
Built with
HTML47%
Python36%
JavaScript12%
Updated today
Python
84%
Apache 2.0

knowhere

AI Development · Developer Tools

2,752

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
83
Repo Health
75
Technical
69
Dependency
Built with
Python84%
HTML15%
Updated today
Python
68%
MIT

Langflow

AI Agents · AI Development

153,880

Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.

View details
90
Repo Health
85
Technical
65
Dependency
Built with
Python68%
TypeScript23%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search