PHP code example of drainerlight / php-pdf-decompressor
1. Go to this page and download the library: Download drainerlight/php-pdf-decompressor library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
drainerlight / php-pdf-decompressor example snippets
use PdfDecompressor\Normalizer;
use setasign\Fpdi\Fpdi;
$file = 'modern.pdf';
// Only rewrite the file if it uses features the free parser rejects.
if (Normalizer::isCompressed(file_get_contents($file))) {
(new Normalizer())->normalizeFile($file, $file = 'normalized.pdf');
}
$pdf = new Fpdi();
$pdf->setSourceFile($file); // no more "compression technique not supported"
$pdf->importPage(1);
use PdfDecompressor\Normalizer;
$normalizer = new Normalizer();
// File to file
$normalizer->normalizeFile('input.pdf', 'output.pdf');
// Bytes to bytes
$classicBytes = $normalizer->normalize(file_get_contents('input.pdf'));
bash
composer