PDF libraries for Python
Python has a library for every PDF job:
- pypdf is pure Python with no required dependencies: merge, split, rotate, crop, extract text, fill forms, encrypt and decrypt, edit metadata. The default choice for manipulating files. BSD.
- pdfplumber extracts text with exact positions and is the best tool for pulling tables out of PDFs. It has a visual debugger that draws what it found on the page. Built on pdfminer.six. MIT.
- PyMuPDF wraps MuPDF: the fastest text extraction, page rendering to images, editing, annotations, forms, redaction and table detection. AGPL or commercial.
- pikepdf wraps QPDF: low-level object access, repair of damaged files, merging, page manipulation, AES-256 encryption, XMP metadata. MPL-2.0.
- ReportLab creates PDFs: a canvas for drawing and Platypus for flowing documents with paragraphs, tables and page templates. BSD.
- pdfminer.six is a pure-Python text extractor with a detailed layout model (characters, lines, text boxes, fonts). MIT.
Typical picks: pypdf to merge, split, rotate or encrypt; pdfplumber for tables and positioned text; PyMuPDF for speed and rendering when the AGPL is acceptable; ReportLab to generate documents. For rendering under a permissive license, use pypdfium2 (PDFium bindings).
- pdfminer.six pdfminer.six is a pure-Python library to extract text and layout from PDF files. How to install it, extract text, walk text boxes, lines.
- pdfplumber pdfplumber extracts text, words, characters and tables from PDF files in Python, with exact positions. How to install it, extract text and tables.
- pikepdf pikepdf is a Python library for low-level PDF editing built on QPDF. How to install it, merge and split PDFs, rotate and delete pages, encrypt and decrypt.
- PyMuPDF PyMuPDF is the Python binding for MuPDF: fast text extraction, page rendering, merging, editing, forms and encryption. Installation, license (AGPL).
- pypdf pypdf is a pure-Python library to read and modify PDF files. How to extract text, merge and split PDFs, rotate pages, fill forms, read and write metadata.
- ReportLab ReportLab is the standard Python library for generating PDF documents. How to install it, create a PDF with text, build documents with paragraphs and tables.