https://github.com/dotgksh/php-mupdf
Minimal PDF to image converter using MuPDF
https://github.com/dotgksh/php-mupdf
jpg mupdf mutool pdf pdf-converter php
Last synced: 4 months ago
JSON representation
Minimal PDF to image converter using MuPDF
- Host: GitHub
- URL: https://github.com/dotgksh/php-mupdf
- Owner: dotgksh
- License: mit
- Created: 2022-07-21T16:17:21.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-14T16:14:13.000Z (over 1 year ago)
- Last Synced: 2024-12-04T09:17:45.975Z (over 1 year ago)
- Topics: jpg, mupdf, mutool, pdf, pdf-converter, php
- Language: PHP
- Homepage:
- Size: 28.5 MB
- Stars: 18
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# php-mupdf
Minimal PDF to image converter using [MuPDF](https://mupdf.com/docs/mutool.html). Heavily inspired by [spatie/image-to-pdf](https://github.com/spatie/pdf-to-image).
[](https://packagist.org/packages/karkowg/php-mupdf)
[](https://github.com/dotgksh/php-mupdf/actions?query=workflow%3Atests+branch%3Amain)
[](https://github.com/dotgksh/php-mupdf/blob/main/LICENSE.md)
[](https://packagist.org/packages/karkowg/php-mupdf)
## Install
Via Composer
``` bash
$ composer require karkowg/php-mupdf
```
## Usage
### Convert all the pages to jpg
``` php
$pdf = new Karkow\MuPdf\Pdf('path/to/pdf/file');
$pdf->saveAllPagesAsImages('./images/', 'page-');
```
### Convert a single page to png
``` php
$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.
## [mutool](https://mupdf.com/releases/index.html)
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.
``` php
$pdf = new Karkow\MuPdf\Pdf('path/to/pdf/file', 'path/to/mutool');
```
## Change log
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Testing
``` bash
$ composer test
```
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.
## Security
If you discover any security related issues, please email karkowg@gmail.com instead of using the issue tracker.
## Credits
- [Gustavo Karkow][link-author]
- [All Contributors][link-contributors]
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
[ico-version]: https://img.shields.io/packagist/v/karkowg/php-mupdf.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/karkowg/php-mupdf/master.svg?style=flat-square
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/karkowg/php-mupdf.svg?style=flat-square
[ico-code-quality]: https://img.shields.io/scrutinizer/g/karkowg/php-mupdf.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/karkowg/php-mupdf.svg?style=flat-square
[link-packagist]: https://packagist.org/packages/karkowg/php-mupdf
[link-travis]: https://travis-ci.org/karkowg/php-mupdf
[link-scrutinizer]: https://scrutinizer-ci.com/g/karkowg/php-mupdf/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/karkowg/php-mupdf
[link-downloads]: https://packagist.org/packages/karkowg/php-mupdf
[link-author]: https://github.com/karkowg