php-pdfium

pdfium is a PHP extension for reading, rendering, splitting and merging PDF files. It is built on Google’s PDFium, the PDF engine inside Chrome.

Pages load only when you ask for them, so walking a long document does not hold every page in memory.

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");
}

These docs cover version 0.1.0, built against PDFium chromium/8125.