amonger/wkhtmltopdf-api

There is no license information available for the latest version (v1.3.2) of this package.

v1.3.2 2017-06-13 16:08 UTC

This package is auto-updated.

Last update: 2024-12-12 23:18:56 UTC


README

This is a docker micro-service which has a simple api to generate PDFs.

To set up the server

docker build -t wkhtmltopdf .
docker run -d -p 80:80 -v $(pwd)/api:/var/www/html wkhtmltopdf

To put in a PHP project

You'll need to set an Authorization header. This is defined in the .env file in the server code.

require_once "vendor/autoload.php";

use GuzzleHttp\Client;
use PDFGenerator\PDFGenerator;
use PDFGenerator\Implementation\RemotePDF;

$client = new Client([
  'base_uri' => 'http://192.168.0.1:8080',
  'headers'  => ['auth' => '123456789']
]);
$generator = new PDFGenerator(new RemotePDF($client));

header("Content-type:application/pdf");

echo $generator->fromURL('http://www.google.co.uk');