Skip to main content

pdf2pixels

pdf2pixels streams PDF pages as PNG or JPEG images through interchangeable PDFium and Poppler rendering backends.

Installation

The base package has no Python rendering-engine dependency:

python -m pip install pdf2pixels

For the preferred PDFium backend, install the optional extra:

python -m pip install "pdf2pixels[pdfium]"

Alternatively, install Poppler with your operating system's package manager. pdf2pixels uses pdftocairo when available and otherwise uses pdftoppm; it does not download or distribute Poppler binaries.

Usage

Omitting pages renders every page in document order:

from pdf2pixels import convert

for page in convert("document.pdf"):
    with open(f"page-{page.page}.{page.format}", "wb") as output:
        output.write(page.data)

Each PageImage contains the 1-based page number, encoded image bytes, output format, width, and height. Conversion is lazy: the document is opened and the first page is rendered when the iterator is consumed. Resources are released when the iterator is exhausted or closed.

Paths and in-memory PDF bytes are supported:

first_page = next(convert(pdf_bytes, pages=[1], format="jpeg", dpi=300))
selected = list(convert("document.pdf", pages=[3, 1, 3]))

For an interactive walkthrough, open the quickstart notebook, which renders and displays the included sample PDF. Install its dependencies with python -m pip install -e ".[pdfium,examples]".

The options are:

  • backend: "auto" (PDFium, then Poppler), "pdfium", or "poppler".
  • dpi: a positive integer; the default is 150.
  • pages: positive, 1-based page numbers. None renders all pages, and an empty iterable renders no pages. Explicit order and duplicates are preserved.
  • format: "png" or "jpeg". JPEG output uses quality 85.

Invalid arguments, malformed data, encrypted PDFs, and invalid page selections raise ValueError. Missing paths raise FileNotFoundError. Missing renderers and environmental rendering failures raise RuntimeError. Opening and render errors can occur while iterating.

Renderer versions

PDFium support is tested from pypdfium2 5.0 through the latest compatible release, without an upper bound. Poppler support is based on command capability rather than a version number and uses the installation provided by your system. An informed user can try an older, unsupported PDFium release with python -m pip install Pillow pypdfium2==VERSION followed by python -m pip install --no-deps pdf2pixels. Older combinations are outside the tested support range and may contain unpatched security issues; selecting and maintaining renderer versions is the user's responsibility.

Project boundary

Version 0.1 is a rendering library only: it does not fetch URLs, accept PDF passwords, provide a CLI or renderer plugin API, or perform downstream PDF processing.

Development

Create the development environment from the repository root:

conda env create --file environment.yml
conda activate pdf2pixels-dev

The environment installs the project editable with the PDFium, development, and example extras. Build distributions with python -m build, or clean generated build artifacts with python -m hatchling build --clean-only.

License

pdf2pixels is licensed under Apache-2.0. PDFium, pypdfium2, Pillow, Poppler, and their dependencies retain their own licenses and are not relicensed by this project.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdf2pixels-0.1.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdf2pixels-0.1.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file pdf2pixels-0.1.0.tar.gz.

File metadata

  • Download URL: pdf2pixels-0.1.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pdf2pixels-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4d87ccf98121c0d0998241d8660cf36d579ef563abed3ee9242154038dbce0c7
MD5 01a40b5f4e69534783dd40378bcb72cc
BLAKE2b-256 57c2612b7fd5ea14da366e1a11e4900c8bb4a12fc4edae01acdbbd96570478c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdf2pixels-0.1.0.tar.gz:

Publisher: publish.yml on mclint/pdf2pixels

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pdf2pixels-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pdf2pixels-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pdf2pixels-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0fac7f128216274584e8085985655dd07b200c20c554df3a59898bb1b1e40f41
MD5 bb1a44567b32ae163f561aabfd5586ff
BLAKE2b-256 14d9a25b3ee76f4461e12119f0bffc81cfefd9b3ed39af90f09d1902eecfda4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdf2pixels-0.1.0-py3-none-any.whl:

Publisher: publish.yml on mclint/pdf2pixels

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page