basdegroot/phpwkhtmltopdflaravel

Wrapper for the phpwkhtmltopdf package

v1.0.1 2017-11-15 12:21 UTC

This package is not auto-updated.

Last update: 2024-04-28 01:50:23 UTC


README

This wrapper will include the mikehaertl/phpwkhtmltopdf library. It will use the config functions of laravel and it can be configured threw the .env file. All the functions of the library of mikehaertl are available. https://github.com/mikehaertl/phpwkhtmltopdf

Installation

Install the package through composer:

composer require basdegroot/phpwkhtmltopdflaravel

Configuration

The application can be configured threw the .env file or by publishing the configuration files to your project.

Publish

php artisan vendor:publish

.env variables

WKHTMLTOPDF_BINARY = Path to the binary of the WkHtmlToPdf library. Default is 'wkhmltopdf'
WKHTMLTOPDF_INGORE_WARNINGS = Whether to ignore any errors if a PDF file was still created. Default is false
WKHTMLTOPDF_TMP_DIR = Path to tmp directory. Defaults to the PHP temp dir.

Response

The class has an method which returns a Laravel response object with the PDF content + correct headers

use Basdegroot\PhpwkhtmltopdfLaravel\Pdf;

$pdf = new Pdf('http://www.google.nl');
return $pdf->response();

// or with a filename

return $pdf->response('filename'); 


The Pdf object extends \mikehaertl\wkhtmlto\Pdf so all the other methods are still available.

Changelog

Please see CHANGELOG for more information what has changed recently.