Download the PHP package pdftoolkit/pdf-reader without Composer

On this page you can find all versions of the php package pdftoolkit/pdf-reader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pdf-reader

PDF Reader

English | Français

A PHP reader for external PDFs, built around the objects of ISO 32000-1:2008 and ISO 32000-2:2020. It exposes document dictionaries, arrays, references and streams with explicit resolution. Requires PHP 8.3 or newer; CI runs checks on PHP 8.3, 8.4 and 8.5.

This repository complements PDFToolkit/pdf, which provides the primitives and writer. pdftoolkit/pdf-reader depends on that model; the model does not depend on the reader. Both packages use the same objects for names, strings, numbers, arrays, dictionaries and identifiers.

Installation

The package is available on Packagist. In your application:

The core is installed under its canonical Composer name pdftoolkit/pdf:^0.12.2. If your application directly requires roukmoute/pdf, replace that requirement with pdftoolkit/pdf:^0.12.2 and update the lock with Composer. PHP namespaces and APIs are unchanged.

The reader uses pdftoolkit/pdf:^0.12.2, installed automatically by Composer. PHP 8.3 or newer on a 64-bit platform and the ctype, iconv and zlib extensions are required for this combination. The application's composer.lock records the selected versions and revisions.

Version 0.5 accepts PDF 1.0–1.7 and PDF 2.0 syntax, including the catalog /Version /2.0 override, using the same bounded object and stream readers. This makes PDF 2.0 dictionaries available to optional interpreters such as pdftoolkit/pdf-to-html; it does not interpret every PDF 2.0 feature. Standard password and Adobe.PubSec certificate authentication are explicit; unsupported security handlers, codecs and rendering remain explicit limits. See the authentication guide for construction and boundaries.

Reader 0.5 authenticates source PDF MACs with explicit credentials before content interpretation. Both standalone and signature-attached locations are supported; applications can require integrity with SourceIntegrityPolicy::RequirePdfMac. See the source MAC guide for exact coverage and limits.

Reader 0.6 exposes physical revision histories: exact prefixes, xref sections, effective objects and Contents provenance under shared budgets. Raw inspection precedes separate authentication; it grants no signature or modification authority.

External-file data can be supplied through an explicit application object. See the external stream guide for filter selection and bounds.

Reader 0.7 adds explicit import bridge with native reference remapping, bounded cycles and stream policies. Source signatures and encryption authority are not transferred.

Reader 0.8 adds source structure inspection: original tags and typed properties, page/object references, namespace role mappings and associated-file metadata, independently of HTML derivation.

Read pages

Run this example from a reader checkout after composer install. The application loads the file; the reader receives only its bytes.

PageTreeReader::read() traverses /Pages branches and /Page leaves in /Kids order. It checks every /Count, /Parent relationship, descendant identity and traversal limit. The resulting ReadPageTree is countable and iterable; page(0) identifies its first page. Each ReadPage retains its document, reference and source dictionary, then exposes its effective PageAttributes: resources, MediaBox, CropBox and rotation.

DictionaryType::get() always returns the stored value: a reference remains an ObjectReference. ReadDocument::resolve() loads that reference in the relevant document and leaves a direct value unchanged. Previously read objects are kept in a document-scoped cache; there is no global registry, singleton or resolution hidden inside values.

Inherited attributes use the closest ancestor that defines them. A local resource dictionary replaces inherited resources without merging them. The page guide explains inheritance and distinguishes written values from effective values. Traversal does not load contents or every resource of each page.

Read stream bytes

PageContentsReader resolves /Contents into an ordered collection of encoded streams. It receives the document and its own per-page stream limit. Continuing the preceding example with the first page of this fixture:

A page with no /Contents, null or an empty array yields an empty collection. Array streams keep their order, without automatic concatenation or decoding. An EncodedStream retains its dictionary and bytes ready for decompression; originalEncodedBytes() retains the original source ciphertext when authenticated; streamData() requests decoding. The result remains bytes: drawing operators, fonts and encodings are not interpreted to extract text or render a page.

Current coverage

Mechanism Available reading
Syntax Escaped names and strings, integers and reals, booleans, null, arrays, dictionaries, indirect references.
Structure PDF 1.0–1.7 and 2.0 headers and catalog versions; indirect objects and streams delimited by /Length, including indirect lengths.
Traditional xref Subsections, offsets, generations, free objects and revisions linked by /Prev.
Xref streams /W fields, /Index ranges, free, direct or compressed types; unknown types yield an unavailable object.
Hybrid xref /XRefStm entries override the companion table; the table trailer owns /Prev; cumulative budgets cover both.
Object streams /ObjStm members, with header, offset and expected object number validation.
Filters FlateDecode, LZWDecode (EarlyChange 0/1), ASCIIHexDecode, ASCII85Decode and RunLengthDecode; explicit filter chains and parameters.
Images CCITT fax in PHP; DCT, JPX and JBIG2 through qualified native filters or the optional PHP codec package. Exact profiles and metadata.
Predictors TIFF 2 and PNG 10 to 15, with 1-, 2-, 4-, 8- and 16-bit components.
Resolution A missing, free or different-generation object yields NullType.
Page tree Complete ordered traversal, checks for every /Count and /Parent, rejection of cycles or repeated descendants, dedicated traversal limits.
Inheritance Effective resources, MediaBox, CropBox and rotation; CropBox defaults to MediaBox and absent rotation defaults to zero.
Page contents A stream or an array of streams, kept in order; separate reading and decoding.

Without explicit credentials, encrypted files raise EncryptedPdfException. Native Standard-handler authentication supports R2–R7 and named crypt filters; source PDF MACs are verified before protected content is interpreted. Both standalone and signature-attached MACs are supported; applications can require one with SourceIntegrityPolicy::RequirePdfMac. Adobe.PubSec authentication supports explicit recipient capabilities, independent filter keys and deferred attachment access. See the PDF MAC guide. Unavailable codecs and unsupported image profiles are explicitly rejected. A stream using an unknown codec can be preserved in encoded form; requesting decoding raises UnsupportedPdfFeature.

The import bridge copies selected graphs into the writer. Document merging, content rewriting, text extraction, rendering, forms, signature validation and PDF repair remain separate mechanisms. Source references and streams still reject direct serialization; import creates new native identities.

Development

Tests cover syntax, filters, structures, pages and budgets. The five structure fixtures and two page fixtures are generated with pypdf and qpdf, independently of the PHP writer; their bytes and results are checked when reproduced.

The reader validates a structure when it is loaded. Opening the catalog does not perform an exhaustive audit of every object in the file. Consult the security controls and limits before choosing budgets for an upload service.

Documentation

Patch 0.3.1 corrects catalog-only metadata exemption and resolves indirect stream types before selecting embedded-file encryption. Page and object metadata stay protected by their chosen filter; explicit Identity and codec bytes are preserved.

MIT licence.


All versions of pdf-reader with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-ctype Version *
ext-zlib Version *
pdftoolkit/pdf Version ^0.12.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pdftoolkit/pdf-reader contains the following files

Loading the files please wait ...