patrickvandewal/laravel-kc-pdf-service

Wrapper for the KingsCode HTML to PDF service.

0.9 2022-06-07 13:20 UTC

This package is auto-updated.

Last update: 2024-06-07 18:20:48 UTC


README

Packagist Packagist license

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

  1. Create an endpoint within your application which can process and store the PDF file from the service.

  2. Register the service url and API token in your .env file.

    KC_HTML_TO_PDF_SERVICE_URL=
    KC_HTML_TO_PDF_AUTH_TOKEN=
    
  3. Create a KCHtmlToPdfOptions options class

    $options = new KCHtmlToPdfOptions(
    '<your callback url>,
    '<your callback token>'
    );
    

    Optional arguments: landscape and printBackground

  4. Implement the client contract in your controller and call the createDocument method. Provide the html as the first argument and your options as the second.

    $client->createDocument(<your html>, $options)