Search by

chaikivskyi / php-pdfium

chaikivskyi

Fast native PDF extension for PHP, built on PDFium

Package info

github.com/chaikivskyi/php-pdfium

Type:php-ext

Ext name:ext-pdfium

pkg:composer/chaikivskyi/php-pdfium

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

0.1.0 2026-11-07 23:17 UTC

This package is auto-updated.

Last update: 2026-11-07 23:43:24 UTC


README

A native PHP extension for fast PDF work, built on Google's PDFium. Open, read, render, split and merge PDFs; pages load on demand, so long documents stay cheap.

PHP 8.2 to 8.5, NTS and ZTS, on Linux x86_64 and arm64 and macOS arm64.

Documentation: https://php-pdfium.readthedocs.io/

Install

You need libpng and libjpeg first:

# Debian / Ubuntu
sudo apt-get install -y libpng-dev libjpeg-dev pkg-config

# Alpine
apk add libpng-dev libjpeg-turbo-dev pkgconf

# macOS (Homebrew)
brew install libpng jpeg-turbo pkg-config

Then install with PIE:

pie install chaikivskyi/php-pdfium

The build downloads the pinned PDFium release for your platform and checks its checksum, and the install puts it next to the extension. Without internet access, download a pdfium-binaries release yourself and pass --with-pdfium=DIR.

Or build from source:

git clone https://github.com/chaikivskyi/php-pdfium
cd php-pdfium
phpize
./configure
make
sudo make install

Add extension=pdfium to php.ini if it is not there yet.

Usage

Extract text and render every page:

use Pdfium\Document;

$doc = Document::fromFile('/path/file.pdf');

foreach ($doc as $page) {
    echo $page->text();
    $page->render(dpi: 150)->savePng("/tmp/page-{$page->index()}.png");
}

Split and merge:

$doc->extractPages([0, 1, 4])->save('/tmp/subset.pdf');
Document::merge([$docA, $docB])->save('/tmp/all.pdf');

Licence

MIT, see LICENSE. PDFium is BSD-3-Clause / Apache-2.0; its licence files come with the prebuilt binaries and must accompany any distribution that bundles them.