pdfmatrix.com JSON API Documentation
You can install the package via composer:
composer require gdinko/pdfmatrix-sdk
If you need to export configuration file:
php artisan vendor:publish --tag=pdfmatrix-config
Add this to .env file:
PDFMATRIX_API_TOKEN= #Get API token from pdfmatrix.com
use Gdinko\PdfMatrix\Facades\PdfMatrix;
$me = PdfMatrix::me();
dd($me);
Methods
use Gdinko\PdfMatrix\Facades\PdfMatrix;
//Account information
PdfMatrix::me(): array
//PDF Generation
PdfMatrix::pdf(PdfRequestInterface $request)
//PDF Storage
PdfMatrix::listMyFiles(): array
PdfMatrix::getFile($hash): string
PdfMatrix::deleteFile($id): array
Get information about pdfmatrix API usage
$me = PdfMatrix::me();
dd($me);
List my files stored on pdfmatrix.com cloud
$response = PdfMatrix::listMyFiles();
dd($response);
Generate pdf from url and get JSON response from pdfmatrix.com
use Gdinko\PdfMatrix\Facades\PdfMatrix;
use Gdinko\PdfMatrix\Requests\PdfRequest;
use Gdinko\PdfMatrix\Exceptions\PdfMatrixException;
use Gdinko\PdfMatrix\Exceptions\PdfMatrixValidationException;
try {
$jsonResponse = PdfMatrix::pdf(
new PdfRequest([
'url' => 'https://pdfmatrix.com',
])
);
dd($jsonResponse);
} catch (PdfMatrixException $e) {
echo $e->getCode() . '<br />';
echo $e->getMessage() . '<br />';
print_r($e->getErrors());
} catch (PdfMatrixValidationException $ve) {
echo $ve->getCode() . '<br />';
echo $ve->getMessage() . '<br />';
print_r($ve->getErrors());
}
Generate pdf from url and send it for download to the browser
use Gdinko\PdfMatrix\Facades\PdfMatrix;
use Gdinko\PdfMatrix\Requests\PdfRequest;
use Gdinko\PdfMatrix\Exceptions\PdfMatrixException;
use Gdinko\PdfMatrix\Exceptions\PdfMatrixValidationException;
try {
return PdfMatrix::pdf(
new PdfRequest([
'url' => 'https://pdfmatrix.com',
'return' => 'download'
])
);
} catch (PdfMatrixException $e) {
echo $e->getCode() . '<br />';
echo $e->getMessage() . '<br />';
print_r($e->getErrors());
} catch (PdfMatrixValidationException $ve) {
echo $ve->getCode() . '<br />';
echo $ve->getMessage() . '<br />';
print_r($ve->getErrors());
}
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email dinko359@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.