gdinko / pdfmatrix-sdk
pdfMatrix Laravel SDK
v1.0.0
2022-10-03 22:00 UTC
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-09-30 02:08:00 UTC
README
安装
您可以通过composer安装此包
composer require gdinko/pdfmatrix-sdk
如果您需要导出配置文件
php artisan vendor:publish --tag=pdfmatrix-config
配置
将此内容添加到 .env 文件中
PDFMATRIX_API_TOKEN= #Get API token from pdfmatrix.com
用法
use Gdinko\PdfMatrix\Facades\PdfMatrix; $me = PdfMatrix::me(); dd($me);
方法
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
示例
获取关于pdfmatrix API使用的详细信息
$me = PdfMatrix::me(); dd($me);
列出存储在pdfmatrix.com云上的我的文件
$response = PdfMatrix::listMyFiles(); dd($response);
从url生成pdf,并从pdfmatrix.com获取JSON响应
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()); }
从url生成pdf,并将其发送到浏览器下载
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
变更日志
请参阅 CHANGELOG 了解最近更改的详细信息。
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全
如果您发现任何安全相关的问题,请发送电子邮件到 dinko359@gmail.com 而不是使用问题跟踪器。
鸣谢
许可证
MIT许可证(MIT)。请参阅 许可证文件 了解更多信息。