PdfParser
Standalone PHP library to extract text, metadata, and data from PDF files with no external tools.
Repository Health
Technical Analysis
smalot/PdfParser is a standalone PHP library that reads and parses PDF documents to extract their text, metadata, and structural data. It works entirely in PHP without shelling out to external binaries like pdftotext, which makes it easy to deploy in restricted or shared hosting environments.
Widely used across CMS platforms, search indexers, and document pipelines, PdfParser can load a PDF from a file or raw string, walk its objects and pages, pull out author and creation metadata, and return extracted text for individual pages or the whole document.
What You Get
- A Parser that loads PDFs from a file path or a raw string
- Full-document and per-page text extraction via getText()
- Metadata extraction including author, title, and creation/modification dates
- Access to low-level PDF objects, headers, and page structures
- Configurable parsing behavior for fonts, encodings, and data-URI handling
Common Use Cases
- Extracting text from uploaded PDFs for full-text search indexing
- Reading PDF metadata in document management systems
- Converting PDF content to plain text in server-side pipelines
- Scraping structured data from generated invoices or reports
Under The Hood
Architecture - The library under src is built around a Parser that tokenizes the raw PDF stream into indirect objects, then models them as a Document composed of Element, Object, Page, and Font types. Text extraction resolves content streams, decodes font encodings and CMaps, and reassembles positioned glyphs into readable strings; a Config object controls behaviors like font handling and data-URI decoding. Metadata is read from the document trailer and info dictionary.
Tech Stack - Pure PHP distributed via Composer with PSR autoloading, requiring no external system binaries. Quality tooling includes PHPStan, PHP-CS-Fixer (via a CS workflow), and Scrutinizer analysis, orchestrated through a Makefile.
Code Quality - The project has a substantial PHPUnit test suite with sample PDFs, CI and code-style workflows, and static analysis configured. It is a mature codebase, though the maintainers note it is under limited maintenance with no active feature development.
API Design - The entry point is small and intuitive: construct a Parser, call parseFile() or parseContent(), then getText() or getDetails(). This ergonomic surface hides considerable PDF-format complexity, and the pdfparser.org documentation plus bundled samples ease onboarding.
Used by 2 apps in this directory
Krayin CRM
Ecommerce · CRM
Free, open-source Laravel & Vue.js CRM for SMEs and enterprises to manage the complete customer lifecycle.
Yaffa
Invoicing Finance
Self-hosted personal finance app for long-term financial planning with AI-powered transaction parsing and investment tracking.