gdinko / pdfmatrix-sdk
pdfMatrix Laravel SDK
Installs: 6 123
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.0
- guzzlehttp/guzzle: ^7.4
- illuminate/support: ^8.0|^9.0
Requires (Dev)
- nunomaduro/collision: ^5.11
- nunomaduro/larastan: ^1.0
- orchestra/testbench: ^6.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.2
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.1
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-10-30 02:26:50 UTC
README
pdfmatrix.com JSON API Documentation
Installation
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
Configuration
Add this to .env file:
PDFMATRIX_API_TOKEN= #Get API token from pdfmatrix.com
Usage
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
Examples
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()); }
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email dinko359@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.