Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Pdfparser Laravel Package

smalot/pdfparser

Standalone PHP library to extract data from PDF files: parse objects and headers, read metadata, pull text from ordered pages, and handle compressed PDFs. Install via Composer. Note: limited maintenance; secured documents and form data extraction aren't supported.

View on GitHub
Deep Wiki
Context7

smalot/pdfparser is a standalone PHP library for extracting data from PDF files — no external dependencies required. It parses objects and headers, reads document metadata, and pulls ordered text from pages, making it a practical choice for indexing, search, or content migration in Laravel and PHP applications. Install it via Composer (composer require smalot/pdfparser) and parse a file in just a few lines.

The project is under limited maintenance: PHP compatibility is kept current and small contributions are welcome, but there is no active feature development. Note that secured documents and form data extraction are not supported.

  • Load and parse PDF objects and headers
  • Extract metadata such as author and description
  • Extract text from ordered pages
  • Handle compressed PDFs, hex/octal encoding, and Mac OS Roman charset
  • Define custom configurations for tailored parsing
Frequently asked questions about Pdfparser
How do I install smalot/pdfparser in a Laravel application?
Install it with Composer by running composer require smalot/pdfparser in your Laravel project root. The package is a standalone PHP library with no external dependencies beyond PHP, so Laravel's Composer-based dependency system handles it without framework-specific changes. Composer will update your composer.json and lock file, and the parser classes are autoloaded like any other package.
Is smalot/pdfparser compatible with Laravel 10 and Laravel 11?
Yes, it works through Composer and does not require Laravel-specific integration. The library requires PHP 7.1+ since v1, and recent fixes target PHP 8.1+ behavior, which aligns with the PHP versions Laravel 10 and 11 typically run. Still, pin a stable release and test against your app's PHP version and PDF corpus before upgrading.
How do I extract text from a PDF in Laravel with smalot/pdfparser?
Create a Smalot\PdfParser\Parser instance, call parseFile on the PDF path, then call getText on the returned document object. In Laravel you can wrap this in a service class, job, or controller and store the extracted text in your database or pass it to Laravel Scout. The README quick example uses parser->parseFile('/path/to/document.pdf') and $pdf->getText().
Can smalot/pdfparser extract metadata such as author and title from a PDF?
Yes, the library can extract metadata including author and description, and it also exposes parsed objects and headers. Use the document object returned by the parser and call its metadata methods; see the package usage documentation for exact method names. Metadata extraction is one of the core PDF-specific features alongside text extraction.
Should I use smalot/pdfparser v2.13.0-beta1 in production?
No. The maintainer explicitly marks v2.13.0-beta1 as beta and warns it may contain changes that could affect production systems. Pin production to v2.12.5 and treat the beta as a staging or evaluation target only. The 2.13 line rewrites core internals such as incremental object construction and chunked section parsing, so extraction output on borderline documents may differ.
Is smalot/pdfparser actively maintained?
The project is under limited maintenance. It is kept compatible with supported PHP versions and community fixes may be accepted, but there is no active feature development and no guarantee that pull requests will be reviewed or merged quickly. Recent first-time contributor fixes are a modest positive signal, but treat the library as feature-stable and security-patch-oriented rather than roadmap-driven.
Does smalot/pdfparser support encrypted or password-protected PDFs?
No, secured documents are not supported unless you manually decrypt or pre-process them before parsing. The README lists secured documents as unsupported, along with form data extraction. If your Laravel upload flow accepts password-protected PDFs, plan a separate decryption or rejection path.
Can smalot/pdfparser extract filled-in PDF form data?
No, form data extraction is explicitly listed as unsupported. The library focuses on text, metadata, headers, and parsed objects rather than AcroForm field values. For form-heavy workflows you will need a different tool or custom handling.
What are the memory and denial-of-service risks of parsing untrusted PDFs with smalot/pdfparser?
The 2.13 line materially improves memory and DoS posture with chunked section parsing, incremental object building, and removal of a quadratic-time placeholder replacement path. Those changes reduce peak memory and make adversarial input scaling linear on that path, but they do not eliminate risk. For untrusted uploads in Laravel, combine the parser with file size limits, queue workers, timeouts, and isolated processing.
How should I test a smalot/pdfparser upgrade in a Laravel app?
Diff-test the new version against a golden corpus of real production PDFs and compare extracted text and metadata with the currently pinned release. Include malformed or nested PDFs that exercise the Font::getDetails() indirect Encoding TypeError fixed in PR #823 and PHP 8.1+ float-to-int cast case fixed in PR #841. Because the beta rewrites parser internals, do not rely on unit tests alone; validation needs representative documents.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource