atk14 / pdficate-client
Pdficate.com客户端 - HTML转PDF转换器
v0.1.2
2022-10-10 20:25 UTC
Requires
- php: >=5.3.0
- atk14/files: 1.* >=1.3.1
- atk14/url-fetcher: 1.* >=1.3
Requires (Dev)
- atk14/tester: *
This package is auto-updated.
Last update: 2024-09-11 00:57:13 UTC
README
这是Pdficate.com的客户端 - URL转PDF转换器与截图工具。客户端使用PHP编写。
1. 使用方法
在配置文件中设置PDFICATE_API_KEY常量。
define("PDFICATE_API_KEY","123.abcdefghijklmnopqrst");
为了获取PDFICATE_API_KEY,您需要在https://pdficate.com/en/users/create_new/注册。目前Pdficate是封闭测试版。因此,您需要一个邀请码来获取密钥。
$client = new Pdficate\Client();
$filename = $client->printToPdf("https://www.atk14.net/");
当发生错误时,会抛出一个带有适当消息的异常。
构造函数中也有一些可选的参数。
$client = new Pdficate\Client([
"page_size" => "A4", // A4, A3, Letter
"margin_top" => "2cm",
"margin_right" => "2cm",
"margin_bottom" => "2cm",
"margin_left" => "2cm",
"delay" => 0, // ms, the delay before printing to ensure that the page is fully loaded, intended for pages with a JS loading effect and so on
]);
还有一个截图工具。
$screenshoter = new Pdficate\Client\Screenshoter([
"width" => 1024,
"height" => 768,
// the offset setting has no effect on the final image size specified in the width and height options
"offset_top" => 0,
"offset_right" => 0,
"offset_bottom" => 0,
"offset_left" => 0,
"delay" => 0, // ms, the delay before printing to ensure that the page is fully loaded, intended for pages with a JS loading effect and so on
"image_format" => "jpeg", // "png", "jpeg"
]);
$filename = $screenshoter->screenshot("https://www.atk14.net");
2. 安装
使用Composer安装Pdficate客户端。
cd path/to/your/project/
composer require atk14/pdficate-client
3. 许可证
Pdficate客户端是免费软件,根据MIT许可证条款进行分发。