A Class for working with a PDFreactor service.
- PHP 7.0+
- ext-curl
- ext-json
composer require ssgglobal/pdf-reactor
The library needs information in order to connect to the PDFreactor REST service.
- API URL - The server host (e.g. http://mypdfreactorserver.com).
- API PORT - Port number the server is listening on (default: 9423)
- API KEY - Your API key to access the service (OPTIONAL).
- ADMIN KEY - A key that is required if you use the server monitor API.
Publish the PDFreactor config
php artisan vendor:publish
Add pdfreactor settings to .env and/or .env.example
PDFREACTOR_HOST=http://mypdfreactorserver.com
PDFREACTOR_PORT=9423
PDFREACTOR_KEY=
PDFREACTOR_ADMIN_KEY=
(Optional) Add an Alias for PDFreactor
// config/app.php
[
'aliases' => [
'PDFreactor' => StepStone\PDFreactor\Facades\PDFreactor::class,
],
]
use StepStone\PDFreactor\PDFreactor;
$pdfreactor = new PDFreactor($host, $port);
$config = [
'document' => file_get_contents('data_to_convert.html'),
]
$result = $pdfreactor->convertAsync($config);
use StepStone\PDFreactor\Convertable;
// from a file
$config = Convertable::create('<p>My PDF</p>');
// or read from a file - Convertable::createFromFile('data_to_convert.html');
$result = $pdfreactor->convertAsync($config);
use PDFreactor;
use StepStone\PDFreactor\Convertable;
$config = Convertable::create('<p>My PDF</p>');
$result = PDFreactor::convertAsync($config);
For more information about available methods look at the PDFreactor and Monitor Classes.