PdfParser

Standalone PHP library to extract text, metadata, and data from PDF files with no external tools.

Library
Composer
vv2.12.5
2,724stars
LGPL-3.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
62/100Good
Development Activity24
Maintenance36
Community88
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture80
Code Quality80
Innovation76
Learning Curve82

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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search