patrickvandewal / laravel-kc-pdf-service
Wrapper for the KingsCode HTML to PDF service.
0.9
2022-06-07 13:20 UTC
Requires
- php: >=8.0
- guzzlehttp/guzzle: ^7.3
- laravel/framework: ^8.0|^9.0
Requires (Dev)
- mockery/mockery: 1.5.0
- phpunit/phpunit: ^8.0
README
A Laravel wrapper for the KingsCode HTML to PDF service.
Installation
Require the package.
composer require patrickvandewal/laravel-kc-pdf-service
Optionally, publish the package's configuration file by running:
php artisan vendor:publish --provider="KingsCode\LaravelHtmlToPdf\KCHtmlToPdfServiceProvider"
Usage
-
Create an endpoint within your application which can process and store the PDF file from the service.
-
Register the service url and API token in your
.env
file.KC_HTML_TO_PDF_SERVICE_URL= KC_HTML_TO_PDF_AUTH_TOKEN=
-
Create a
KCHtmlToPdfOptions
options class$options = new KCHtmlToPdfOptions( '<your callback url>, '<your callback token>' );
Optional arguments:
landscape
andprintBackground
-
Implement the client contract in your controller and call the
createDocument
method. Provide thehtml
as the first argument and your options as the second.$client->createDocument(<your html>, $options)