Minimal PDF to image converter using MuPDF. Heavily inspired by spatie/image-to-pdf.
Via Composer
$ composer require karkowg/php-mupdf
$pdf = new Karkow\MuPdf\Pdf('path/to/pdf/file');
$pdf->saveAllPagesAsImages('./images/', 'page-');
$pdf = new Karkow\MuPdf\Pdf('path/to/pdf/file');
$pdf
->setPage(2)
->setOutputFormat('png')
->saveImage('./images/page-2.png');
Please refer to tests/PdfTest.php
for other use cases.
A compiled binary (v1.20.0) is available at bin/mutool
. If for any reason you want/need to use your own installation, you can do so by passing its path as a 2nd argument to the constructor.
$pdf = new Karkow\MuPdf\Pdf('path/to/pdf/file', 'path/to/mutool');
Please see CHANGELOG for more information on what has changed recently.
$ composer test
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
- Gustavo Karkow
- [All Contributors][link-contributors]
The MIT License (MIT). Please see License File for more information.