renderpdf-io / renderpdf-laravel
Render and covert HTML to PDF using RenderPDF.io service, library for Laravel
1.0.0
2024-08-03 14:19 UTC
Requires
- php: ^8.1
- laravel/framework: ^10|^11|dev-master
Requires (Dev)
- mockery/mockery: ^1.6
- orchestra/testbench: ^8|^9
- phpunit/php-code-coverage: ^10
- phpunit/phpunit: ^10
README
RenderPDF.io provides awesome & developer-friendly APIs to convert HTML to PDF.
This is a Laravel package provides an easy integration with RenderPDF.io
Requirement
- PHP 8.1 and above
- Laravel 10 and above
Installation
composer install renderpdf-io/renderpdf-laravel
Note: for Laravel 10 users, you need to install GuzzleHTTP
too.
Add the services.renderpdf-io.key
config into your config/services.php
(required):
// config/services.php return [ 'renderpdf-io' => [ 'key' => env('RENDER_PDF_IO_API_KEY'), ], ];
Usage
Facade style
Simply use the RenderPdfIo
facade
use RenderPdfIo\RenderPdfIo; use RenderPdfIo\Services\RenderPdfOptions; public function renderPdf() { $fileUrl = RenderPdfIo::render(new RenderPdfOptions( htmlContent: '<p>This is a new PDF</p>', )); }
Dependency Injection style
In case you want to use DI style, we got you:
use RenderPdfIo\Services\RenderPdfIoService; use RenderPdfIo\Services\RenderPdfOptions; class InvoiceController { public function download(RenderPdfIoService $renderPdfService) { $fileUrl = $renderPdfService->render(new RenderPdfOptions( htmlContent: '<p>This is a new PDF using DI</p>', )); } }
See all the available options here: RenderPdfOptions.php
Contributing
Thank you for your consideration to contribute to Laravel library of RenderPDF.io, please feel free to:
- Open an issue for bug reports.
- Submit a PR for improvements/enhancements.
License
This library is free to use, under MIT License.