A simple client for the DocRaptor API, written in PHP5.
- Convert HTML to PDF and HTML to Excel through the DocRaptor API.
- PHP >= 5.3.2 with cURL extension
Using composer, add the following to composer.json:
{
"require": {
"bytes/docraptor": "dev-master@dev"
}
}
<?php
use Bytes\Docraptor\Document\PdfDocument;
use Bytes\Docraptor\Http\Client as HttpClient;
use Bytes\Docraptor\Client;
$document = new PdfDocument('<Document name>');
$html = '<some html goes here>';
$document->setContent($html);
$httpClient = new HttpClient();
$client = new Client($httpClient, 'YOUR_API_KEY_HERE');
try {
$pdf = $client->setTestMode(true)->convert($document);
// write to file, stream to user, etc.
} catch (DocraptorException $e) {
echo($e);
}