- How do I install 1tomany/pdf-pack in a Laravel app?
- Install the PHP package with composer require 1tomany/pdf-pack. You must also install Poppler so the pdfinfo, pdftoppm, and pdftotext binaries are available on your PATH; use brew install poppler on macOS or apt-get install poppler-utils on Debian/Ubuntu. In Laravel, you can instantiate PopplerClient directly or bind ClientInterface to a client in a service provider for dependency injection.
- Does pdf-pack support Laravel out of the box?
- No. pdf-pack is a framework-agnostic PHP library with no Laravel service provider, auto-discovery, facade, config stub, or job examples. A Symfony bundle exists for container wiring and configuration, but it does not provide Laravel integration. You can still use it in Laravel by resolving or binding ClientInterface yourself and owning any queue or job orchestration.
- What Poppler binaries does pdf-pack require and how do I install them?
- The package requires pdfinfo for metadata and page counts, pdftoppm for rasterizing pages to JPEG or PNG, and pdftotext for text extraction. All three must be installed and discoverable on the runtime PATH. Install them with brew install poppler on macOS or apt-get install poppler-utils on Debian and Ubuntu, and make sure your local, CI, container, and production environments all include them.
- How do I extract text from a PDF with pdf-pack?
- Use PopplerClient directly or resolve ClientInterface through ClientFactory, then call the text extraction feature for one or more pages. The library returns a Generator that yields results per page, so you can iterate and concatenate, write each page to disk, or pass text into another pipeline without buffering the whole document. This is text-layer extraction only, so scanned or image-only PDFs may return empty or partial text.
- Can pdf-pack convert PDF pages to JPEG or PNG images?
- Yes. pdf-pack rasterizes PDF pages to JPEG or PNG through pdftoppm and returns a Generator with one result per extracted page. Results are held in memory, so you can write them to the filesystem or convert them to a data URI, optionally using the 1tomany/data-uri package. For large documents, write pages as they are generated instead of collecting everything first.
- Does pdf-pack support OCR for scanned PDFs?
- No. pdf-pack wraps Poppler text extraction, which reads an existing text layer and does not perform OCR. Scanned documents, image-only PDFs, and many signed or stamped PDFs can return empty or partial text. If more than a small share of your corpus needs OCR, plan for a separate OCR path rather than treating pdf-pack as a complete document AI solution.
- How do I test Laravel code that uses pdf-pack?
- Depend on ClientInterface rather than instantiating PopplerClient deep inside your application code, and use ClientFactory or Laravel's container to inject a fake or stub client in unit tests. That lets you test your extraction, storage, and queue logic without Poppler installed. Keep a smaller set of integration tests that run against real pdfinfo, pdftoppm, and pdftotext binaries to catch environment and version differences.
- What PHP and Laravel versions does pdf-pack support?
- pdf-pack requires PHP 8.1 or newer and Composer, with symfony/process as its only dependency. It has no Laravel framework constraint because it is not Laravel-specific, so it can be used in modern Laravel applications that support PHP 8.1+, but you should verify compatibility with your exact Laravel and Symfony Process versions. Poppler versions also differ across operating systems, so pin the binary in your runtime image where reproducibility matters.
- How do I handle memory and large PDFs with pdf-pack?
- The Generator-per-page return type is the key memory control: process pages one at a time and write or forward each result instead of accumulating the whole document. Each page still spawns a Poppler CLI process, so avoid unbounded parallel fan-out across pages or queue workers. For Laravel, chunk page ranges into jobs, limit worker concurrency, and avoid building huge data URIs for large rasterized pages.
- Is pdf-pack production-ready for a Laravel PDF pipeline?
- Treat it as a thin, useful wrapper rather than a complete platform. The project is pre-1.0, single-maintainer, has few dependents, and has no documented security advisory process; breaking changes have occurred in minor releases. Pin the version and be prepared to vendor or replace it if needed, and budget for owning the Laravel service provider, error mapping, timeouts, observability, and job orchestration yourself.