wyzen-packages / htmltopdf
HTML 到 PDF API 调用者
v2.0.0
2022-09-28 15:48 UTC
Requires
- php: >=8.1
- ext-json: *
- guzzlehttp/guzzle: ^7.5
- wyzen-packages/simple-jwt: ^1.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.7
- symfony/var-dumper: ^6.1
This package is auto-updated.
Last update: 2024-09-28 20:19:57 UTC
README
用于使用 Wyzen HTMLtoPDF 服务的库
所需
需要 Wyzen htmlToPdf 服务
导入
composer require wyzen-packages/htmltopdf
选项
从 URL 或 HTML
- 从 HTML 或 HTML64 源
$options = [ "html" => "<h2>PDF from html code inline</h2>", //"html64" => "html encoded base64" ] - 从 URL 源
$options = [ "url" => "https://www.google.com", ]
通用
$options = [
"options" => [
"common" => [
"javascript-delay" => 1000,
"no-stop-slow-scripts" => true
],
],
];
$options = [
"options" => [
"pdf" => [
"orientation" => "Portrait",
"header-center" => "My header",
"footer-center" => "My footer",
],
],
];
图片
$options = [
"options" => [
"image" => [
"format" => "png",
"width" => 800,
"height" => 600,
],
],
];
使用
use Wyzen\HtmlToPdf;
// Set URL
$htmlToPdf = new HtmlToPdf($_ENV['HTMLTOPDF_URL']);
// Set Auth
$htmlToPdf->setAuth($_ENV['HTMLTOPDF_ACCOUNT'], $_ENV['HTMLTOPDF_KEY']);
// Get HTML Help
$html = $htmlToPdf->getHelp();
// Get PDF response
$response = $htmlToPdf->toPdf($options)->getResponse();
// Get PDF content
$response = $htmlToPdf->toPdf($options)->getContent();
// Get Image response
$response = $htmlToPdf->toImage($options)->getResponse();
// Get Image content
$response = $htmlToPdf->toImage($options)->getContent();