Text extraction is native — no parser library behind it — and works on documents built with embedded fonts, not just the standard fourteen. When a file turns out to be a scan, you can find that out in one call and rasterize its pages to prep for OCR hand-off.
Pull the text out of a document, all of it or page by page. Both arguments are there for volume: name the pages you care about, or cap how many get processed on a file that could be thousands.
Text extraction in the docs →use Pop\Pdf\Pdf; $text = Pdf::extractTextFromFile('report.pdf'); // scope it: pages 1–3 only $text = Pdf::extractTextFromFile( 'report.pdf', [1, 2, 3] ); // or bound the work on a huge document $text = Pdf::extractTextFromFile( 'archive.pdf', null, 50 );
A scanned document looks identical to a real one until you try to read it, and then you get an empty string back with nothing to explain it. One call tells you which you have, so the pipeline can route instead of guess.
Mixed documents — a typed contract with scanned exhibits stapled on the end — report per page.
Detection in the docs →use Pop\Pdf\Pdf; if (Pdf::isImageOnlyDocument('incoming.pdf')) { // every page is a scan } // per-page, for mixed documents $pages = Pdf::getImageOnlyPages('incoming.pdf'); // [0 => true, 1 => false, 2 => true]
One image per page at 300 DPI, written to disk one at a time so memory stays flat no matter how long the document runs. jpg, png, webp and tiff; lossy formats are written at quality 90 to protect OCR accuracy.
Uses the Imagick extension — the one feature that needs it. Pop PDF does not perform OCR; it detects the scans and produces the images an OCR engine takes as input.
Rasterizing in the docs →use Pop\Pdf\Pdf; $images = Pdf::extractAsImages('scan.pdf', 'output/'); // [1 => 'output/scan-01.jpg', 2 => ...] // png, specific pages, custom naming $images = Pdf::extractAsImages( 'scan.pdf', 'output/', 'png', 300, filenameFormat: 'page-%2$02d', pages: [1, 3] );
PHP 8.4+. Optional extensions: gd, imagick, zlib, mbstring.