eddturtle / qpdf-php
PHP wrapper for the qpdf library
Installs: 68 593
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=7.4
- mikehaertl/php-shellcommand: ^1.5.0
Requires (Dev)
- phpunit/phpunit: ~8.0||~9.0||~10.0
This package is auto-updated.
Last update: 2024-11-14 09:38:51 UTC
README
PHP wrapper for the qpdf library.
Currently requires PHP 7.4+ and the qpfd
library installed (sudo apt install qpdf
).
To Install
composer require eddturtle/qpdf-php
Examples:
Merge
$qpdf = new \EddTurtle\Qpdf\Pdf(); $qpdf->addPage(__DIR__ . "/files/TestPdf.pdf"); $qpdf->addPage(__DIR__ . "/files/TestPdf2.pdf"); $result = $qpdf->merge(__DIR__ . "/output/test-merge.pdf"); if (!$result || !empty($qpdf->getError())) { var_dump($qpdf->getError()); } else { var_dump('success'); }
Split a multi page PDF file
$qpdf = new \EddTurtle\Qpdf\Pdf(); $qpdf->addPage(__DIR__ . "/files/TestPdfTwoPage.pdf"); $qpdf->split(__DIR__."/output/test-split.pdf"); if (!$result || !empty($qpdf->getError())) { var_dump($qpdf->getError()); } else { var_dump('success'); } // Results in "/output/" containing 'test-split-1.pdf' and 'test-split-2.pdf'
Rotate a PDF file
$qpdf = new \EddTurtle\Qpdf\Pdf(); $pdf->addPage(__DIR__ . "/files/TestPdfTwoPage.pdf"); $result = $pdf->rotate(__DIR__ . "/output/rotated.pdf", "+90", "1"); if (!$result || !empty($qpdf->getError())) { var_dump($qpdf->getError()); } else { var_dump('success'); } // Results in "/output/rotated.pdf" having its first page rotated 90° clockwise
Count PDF pages
$qpdf = new \EddTurtle\Qpdf\Pdf(); $pdf->addPage(__DIR__ . "/files/TestPdfTwoPage.pdf"); $pdf->addPage(__DIR__ . "/files/TestPdf.pdf"); $count = $pdf->getPageCount(); // Results in $count containing a value of 3