tecnickcom / tc-lib-pdf-parser
PHP library to parse PDF documents
Fund package maintenance!
3.15.2
2026-09-05 07:37 UTC
Requires
- php: ^8.2
- ext-pcre: *
- tecnickcom/tc-lib-pdf-filter: ^2.11
Requires (Dev)
- carthage-software/mago: 1.47.6
- pdepend/pdepend: ^2.16
- phpunit/phpunit: ^11.5 || ^12.5 || ^13.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-05 07:37:36 UTC
README
Parser library for reading and extracting PDF document structures.
💖 Part of the tc-lib-pdf / TCPDF ecosystem (100M+ installs). Sponsor its maintenance →
Overview
tc-lib-pdf-parser parses raw PDF data into the cross-reference and trailer data of the document and an array of its objects, each decoded into a token array.
| Namespace | \Com\Tecnick\Pdf\Parser |
| Author | Nicola Asuni info@tecnick.com |
| License | GNU LGPL v3 - see LICENSE |
| API docs | https://tcpdf.org/docs/srcdoc/tc-lib-pdf-parser |
| Packagist | https://packagist.org/packages/tecnickcom/tc-lib-pdf-parser |
Features
Parsing
- Cross-reference tables and cross-reference streams, including
/Prevchains and incremental updates - Object streams (
/ObjStm) - Indirect references, resolved on demand and bounded against cycles
- Stream decoding through tc-lib-pdf-filter, including the
PredictorofDecodeParms
Limits
- Maximum decoded size of a single stream
- Maximum nesting depth of arrays and dictionaries
- Maximum depth of indirect object resolutions
- Maximum number of chained cross-reference sections
Requirements
- PHP 8.2 or later
- Extension:
pcre - Composer
Configuration
The constructor accepts an array of parameters:
| Parameter | Type | Default | Meaning |
|---|---|---|---|
ignore_filter_errors |
bool |
false |
If true, a stream that fails to decode is kept as raw data instead of raising an exception |
decode_streams |
bool |
true |
If true, decode the stream payloads of the indirect objects while parsing |
max_stream_size |
int |
33554432 |
Maximum size in bytes of a single decoded stream; 0 means unlimited |
Installation
composer require tecnickcom/tc-lib-pdf-parser
Quick Start
<?php require_once __DIR__ . '/vendor/autoload.php'; $raw = file_get_contents('/path/to/document.pdf'); $parser = new \Com\Tecnick\Pdf\Parser\Parser(['ignore_filter_errors' => true]); // $xref holds the cross-reference and trailer data, // $objects the parsed objects keyed as "[object number]_[generation number]" [$xref, $objects] = $parser->parse((string) $raw);
Development
make deps
make help
make qa
Packaging
make rpm make deb
For system packages, bootstrap with:
require_once '/usr/share/php/Com/Tecnick/Pdf/Parser/autoload.php';
Contributing
Contributions are welcome. Please review CONTRIBUTING.md, CODE_OF_CONDUCT.md, and SECURITY.md.