Download the PHP package drainerlight/php-pdf-decompressor without Composer

On this page you can find all versions of the php package drainerlight/php-pdf-decompressor. 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 php-pdf-decompressor

php-pdf-decompressor

Make modern PDFs readable by legacy parsers — in pure PHP.

CI Latest Version Total Downloads PHP Version

Converts PDF 1.5+ files that use compressed cross-reference streams (/Type /XRef) and object streams (/Type /ObjStm) into a classic PDF 1.4 structure that parsers such as the free parser shipped with FPDI can read.

A qpdf-free / Ghostscript-free alternative: no external binaries, no PHP extensions beyond ext-zlib. Works on shared hosting where you can't install anything.

This PDF document probably uses a compression technique which is not supported by the free parser shipped with FPDI.

If you have ever seen that error — this library is the fix.


Why

Modern PDFs (produced by most current tools) store their cross-reference table and many objects compressed. Older, pure-PHP PDF importers — most notably the free parser bundled with FPDI — can't read that and abort. The usual fixes require a system binary:

…which you often can't install (shared hosting, locked-down servers). This library does the same job in pure PHP, so you can normalize a PDF at runtime and hand it straight to FPDI.

Requirements

Installation

Usage

Use it with FPDI

The most common use case — normalize only when needed, then import as usual:

As a library

Command line

Exit codes: 0 success, 1 runtime error (I/O, unreadable/encrypted PDF), 2 usage error.

How it works

The same steps a tool like qpdf performs, implemented from the ISO 32000-1 spec:

  1. Parse the cross-reference table — classic table or compressed cross-reference stream, following /Prev chains and hybrid /XRefStm.
  2. Unpack every object, including those packed inside object streams (ObjStm).
  3. Rewrite everything as uncompressed indirect objects with a classic cross-reference table and a minimal trailer.

If startxref is missing or corrupt, it rebuilds the cross-reference table by scanning the file for object definitions.

What's supported

Feature Status
Compressed cross-reference streams (/XRef)
Object streams (/ObjStm)
/Prev chains + hybrid /XRefStm
Broken / missing startxref (rebuild)
Generation numbers preserved
Encrypted PDFs (/Encrypt) ⛔ detected & rejected (no decryption)
Filters other than FlateDecode (LZW, ASCII85, …) ⛔ not yet
/Extends object-stream chaining ⛔ not yet

See PLANNING.md for the roadmap and known edge cases.

Not affiliated with Setasign or FPDI. This is an independent, clean-room implementation based solely on the public ISO 32000-1 specification. "FPDI" and "qpdf" are named only to describe compatibility and purpose.

FAQ

How do I fix "This PDF document probably uses a compression technique which is not supported by the free parser shipped with FPDI"? That error means the PDF uses a compressed cross-reference stream and/or object streams (PDF 1.5+). Run the file through this library first, then hand the result to FPDI — see Use it with FPDI. No commercial add-on or system binary required.

How can I read a PDF 1.5, 1.6 or 1.7 with FPDI's free parser? Normalize it to a classic PDF 1.4 structure with Normalizer::normalizeFile() and open the output with FPDI as usual.

How do I decompress a PDF in PHP without qpdf or Ghostscript? This library reimplements the relevant part of qpdf --object-streams=disable --stream-data=uncompress in pure PHP. It only needs ext-zlib, so it runs on shared hosting where you can't install binaries.

What are object streams (ObjStm) and cross-reference streams? They are PDF 1.5+ features that pack many objects into one compressed stream and replace the classic xref table with a compressed one. They shrink files but break parsers that only understand the traditional cross-reference table.

Does it decrypt password-protected PDFs? No. Encrypted PDFs (with an /Encrypt dictionary) are detected and rejected with a clear error rather than producing garbage.

Is this a replacement for the commercial FPDI PDF-Parser add-on? It solves the same "compressed PDF won't open" problem for free, from a different angle: instead of teaching the parser to read compressed PDFs, it rewrites the PDF into a form the free parser already understands. It is an independent, clean-room project and is not affiliated with Setasign.

Contributing

Contributions are welcome — see CONTRIBUTING.md. In short: composer install, keep composer test green on PHP 7.4+, and add a test for any new behavior.

License

MIT — see LICENSE.


All versions of php-pdf-decompressor with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-zlib Version *
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 drainerlight/php-pdf-decompressor contains the following files

Loading the files please wait ...