Metadata-Version: 2.4
Name: pylopdf
Version: 0.16.0
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: WebAssembly :: Emscripten
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Python :: Free Threading :: 3 - Stable
Classifier: Programming Language :: Rust
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Dist: pylopdf-fonts-ar>=0.1.1,<0.2 ; extra == 'ar'
Requires-Dist: pylopdf-fonts-he>=0.1.1,<0.2 ; extra == 'he'
Requires-Dist: pylopdf-fonts-hi>=0.1.1,<0.2 ; extra == 'hi'
Requires-Dist: pylopdf-fonts-jp>=0.1.1,<0.2 ; extra == 'jp'
Requires-Dist: pylopdf-fonts-ko>=0.1.1,<0.2 ; extra == 'ko'
Requires-Dist: libcst>=1.8 ; extra == 'migrate'
Requires-Dist: pylopdf-ocr-models>=0.1.0,<0.2 ; extra == 'ocr'
Requires-Dist: pylopdf-fonts-th>=0.1.1,<0.2 ; extra == 'th'
Requires-Dist: pylopdf-fonts-zh-cn>=0.1.1,<0.2 ; extra == 'zh-cn'
Requires-Dist: pylopdf-fonts-zh-tw>=0.1.1,<0.2 ; extra == 'zh-tw'
Provides-Extra: ar
Provides-Extra: he
Provides-Extra: hi
Provides-Extra: jp
Provides-Extra: ko
Provides-Extra: migrate
Provides-Extra: ocr
Provides-Extra: th
Provides-Extra: zh-cn
Provides-Extra: zh-tw
License-File: LICENSE
License-File: NOTICE.md
License-File: LICENSES/AGL-BSD-3-Clause.txt
License-File: LICENSES/APAFML.txt
License-File: LICENSES/Apache-2.0.txt
License-File: LICENSES/PDFium-BSD-3-Clause.txt
Summary: PDF editing, rendering, extraction, and generation for Python, powered by Rust. MIT, no mandatory Python dependencies, lightweight wheels.
Home-Page: https://github.com/yhay81/pylopdf
Author-email: Yusuke Hayashi <yusuke8h@gmail.com>
License-Expression: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/yhay81/pylopdf/blob/main/CHANGELOG.md
Project-URL: Documentation, https://pylopdf.haya.works/
Project-URL: Homepage, https://github.com/yhay81/pylopdf
Project-URL: Issues, https://github.com/yhay81/pylopdf/issues
Project-URL: Source, https://github.com/yhay81/pylopdf

# pylopdf

[![PyPI](https://img.shields.io/pypi/v/pylopdf)](https://pypi.org/project/pylopdf/)
[![CI](https://github.com/yhay81/pylopdf/actions/workflows/ci.yml/badge.svg)](https://github.com/yhay81/pylopdf/actions/workflows/ci.yml)
[![Python](https://img.shields.io/pypi/pyversions/pylopdf)](https://pypi.org/project/pylopdf/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/yhay81/pylopdf/blob/main/LICENSE)

**Edit, render, extract, and create PDFs in Python.**

pylopdf aims to give Python programs complete control of PDF: every feature
of the PDF 2.0 specification read, interpreted, created, edited, and
preserved, including everything that [pymupdf](https://pymupdf.readthedocs.io/)
does with PDF files, through a smaller API of its own. The roadmap defines
the [scope, exclusions, and evidence required for a completeness claim](https://github.com/yhay81/pylopdf/blob/main/ROADMAP.md#completeness-claims);
API stability at v1.0 alone will not establish complete coverage. It is built
on the Rust PDF engines [lopdf](https://github.com/J-F-Liu/lopdf),
[hayro](https://github.com/LaurenzV/hayro), and
[krilla](https://github.com/LaurenzV/krilla), released under the MIT license,
and installs as a single wheel with no required Python dependencies.

[Documentation](https://pylopdf.haya.works/) ·
[Getting started](https://pylopdf.haya.works/getting-started/) ·
[API reference](https://pylopdf.haya.works/api/) ·
[Migrating from pymupdf](https://pylopdf.haya.works/migration/)

> **Status:** pylopdf is pre-1.0. Version 0.16 redesigned its API, as the
> [roadmap](https://github.com/yhay81/pylopdf/blob/main/ROADMAP.md)
> describes; the [migration guide](https://pylopdf.haya.works/migration/)
> covers code written for pymupdf or pylopdf 0.15. Complete control is the
> goal, not yet the state: the roadmap's
> [assessment](https://github.com/yhay81/pylopdf/blob/main/ROADMAP.md#assessment-2026-10-23)
> lists the gaps. The [stability policy](https://pylopdf.haya.works/stability/)
> explains what may change.

## Install

```bash
pip install pylopdf
```

Python 3.11 or newer. Wheels are available for Linux, macOS, and Windows,
including free-threaded Python 3.14t and 3.15t.

Optional extras add fonts and OCR models:

| Extra | Adds |
|---|---|
| `jp`, `ko`, `zh-cn`, `zh-tw` | Japanese, Korean, and Chinese fonts for displaying and writing text |
| `ar`, `he`, `hi`, `th` | Arabic, Hebrew, Hindi, and Thai fonts for writing text |
| `ocr` | An offline OCR engine for scanned pages |

```bash
pip install "pylopdf[jp,ocr]"
```

## Quickstart

```python
import pylopdf

doc = pylopdf.open("input.pdf")
page = doc.pages[0]

# Extract
text = page.text()                     # plain text
words = page.words()                   # words with their positions
hits = page.search("invoice")          # rectangles of each match
tables = page.tables()                 # tables with their cell text
markdown = doc.markdown()              # whole document as Markdown

# Render
page.pixmap(dpi=150).save("page.png")
svg = page.svg()

# Add content
with page.draw() as canvas:
    canvas.text("Approved", (72, 72), size=20, fill=pylopdf.Color(0.8, 0, 0))
    canvas.image((72, 100, 200, 200), "logo.png")
page.annotations.add(pylopdf.Highlight(hits))

# Reorganize pages (fetch pages again with doc.pages[i] afterwards)
del doc.pages[1:3]
doc.pages.extend(pylopdf.open("appendix.pdf").pages)   # append another document

# Save, compressed and without unused objects
doc.save("output.pdf")
```

The [getting started guide](https://pylopdf.haya.works/getting-started/)
covers each area in more detail.

## Features

- **Pages and documents**: merge, split, reorder, rotate, and delete pages;
  table of contents, page labels, metadata, and file attachments
- **Text extraction**: plain or positioned text, search, tables, Markdown
  output, and vertical Japanese/Chinese text
- **Rendering**: pages to PNG or SVG, with parallel rendering of many pages
- **Adding content**: text in any font with proper shaping, images, vector
  drawings, pages from other PDFs, highlights, and links
- **Forms**: fill in form fields
- **OCR**: make scanned pages searchable without installing Tesseract
- **Saving**: compression, cleanup of unused objects, incremental updates that
  keep signatures valid, and AES-256 or AES-128 encryption

## Why pylopdf

- **MIT licensed.** pymupdf is AGPL or commercial.
- **Small and self-contained.** About 7 MB per wheel, with nothing else to
  install, so it fits AWS Lambda and similar environments. It also runs in
  WebAssembly, including [Cloudflare Python Workers](https://pylopdf.haya.works/wasm/).
- **Safe with untrusted files.** Size and complexity limits raise a clear
  `LimitError` instead of exhausting memory; `DocumentLimits.web()` enables
  all of them. See the [security model](https://pylopdf.haya.works/security/).
- **Built for concurrency.** Heavy operations release the GIL, and
  free-threaded Python is supported. See the
  [concurrency guide](https://pylopdf.haya.works/concurrency/).

## Not supported yet

Redaction, editing or deleting annotations, creating form fields, and
validated PDF/A and PDF/UA output are planned; the
[roadmap](https://github.com/yhay81/pylopdf/blob/main/ROADMAP.md) lists them.

Typesetting with HTML and CSS and digital signatures stay with ecosystem
tools. The [ecosystem guide](https://pylopdf.haya.works/ecosystem/) shows how
to pair pylopdf with [typst](https://typst.app/) and
[pyHanko](https://pypi.org/project/pyHanko/) for those.

## Benchmarks

Benchmarks against pymupdf are reproducible from this repository, and the
results include the cases where pylopdf is slower. See the
[benchmark page](https://pylopdf.haya.works/benchmarks/).

## Contributing

Bug reports and pull requests are welcome. Building from source needs a Rust
toolchain and [uv](https://docs.astral.sh/uv/):

```bash
uv sync
uv run pytest
```

[CONTRIBUTING.md](https://github.com/yhay81/pylopdf/blob/main/CONTRIBUTING.md) has the full development guide. Please
report security issues privately through
[GitHub Security Advisories](https://github.com/yhay81/pylopdf/security/advisories/new).

## License

[MIT](https://github.com/yhay81/pylopdf/blob/main/LICENSE). pylopdf is built on [lopdf](https://github.com/J-F-Liu/lopdf),
[hayro](https://github.com/LaurenzV/hayro),
[krilla](https://github.com/LaurenzV/krilla), and
[HarfRust](https://github.com/harfbuzz/harfrust); see [NOTICE.md](https://github.com/yhay81/pylopdf/blob/main/NOTICE.md)
for third-party licenses.

