py-pdf

pypdf: Read and Manipulate PDF Files in Python

pypdf is a pure-Python library for reading PDFs and changing their pages or document data. It suits Python developers who need PDF operations inside scripts or applications without relying on a separate command-line tool.

PythonOther licenseLibraryPDFData Extraction
Stars
10.2k
Forks
1.6k
Stars, last 16 days
+22

Our take

Health score

74/100

How it is scored
Activity
85
Community
88
Issues
66
Pull requests
57

+22 stars in the last 16 days

  • Releases more often than 85% of the projects we track
  • Merges more pull requests than 79% of the projects we track
  • More contributors than 77% of the projects we track

Overview

pypdf provides Python code for working with PDF files. It helps developers automate common document tasks, such as reading text and metadata, rearranging pages, and adding or changing document properties.

Use it when PDF handling needs to be part of a Python script or application. The project also links to pdfly, a separate command-line application built on pypdf.

Key Features

  • Read PDF pages and extract text.
  • Retrieve document metadata.
  • Split and merge PDF files.
  • Crop and transform pages.
  • Create and read annotations.
  • Add custom data and viewing options.
  • Encrypt and decrypt PDFs, with an extra dependency for AES support.

Use Cases

  • Python developers can extract text or metadata as part of a document-processing workflow.
  • Teams can combine, split, or transform PDF pages in scripts and applications.
  • Application developers can add annotations or custom data to generated or existing PDFs.
  • Developers handling protected PDFs can use encryption and decryption features, installing the crypto extra when AES support is needed.

Getting Started

Install with pip:

pip install pypdf

For more examples and configuration details, see the README and documentation.

Alternatives

  • pdfplumber: pdfplumber focuses on extracting text, tables, and positioned objects with layout inspection, while pypdf also edits pages and document data.
  • pdfminer.six: pdfminer.six focuses on detailed text extraction and analysis, including layout and font data, while pypdf also supports PDF modification.
ProjectLanguageLicenseStarsStatus
pypdfPythonOther10.2kNot checked yet
pdfplumberPythonMIT10.8kQuiet
pdfminer.sixPythonMIT7kQuiet

Considerations

  • pypdf is a Python library, so it is suited to code-driven workflows rather than a standalone user interface. The linked pdfly project provides a CLI option.
  • AES encryption and decryption require installing the optional crypto dependencies with pip install pypdf[crypto].
  • The repository's license field is reported as NOASSERTION; check the repository for licensing details before adopting it.

Found this useful?

Share it with someone who would like pypdf.

Comparisons