PDF 生成模板编辑器
开源可视化 PDF 生成引擎,支持自定义模板,并提供面向开发者的 API,灵活构建文档生成流程。
如果您还没有获取许可证密钥,请查看如何获取许可证密钥。
ComPDF Conversion SDK 目前支持通过离线认证验证许可证密钥。
了解:
正确获取许可证密钥,是许可证应用的关键。
<type> 字段判断许可证类型。如果是 <type>online</type> 则为在线许可证,<type>offline</type> 或无该字段则为离线许可证。在线许可证:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<license version="1">
<platform>windows</platform>
<starttime>xxxxxxxx</starttime>
<endtime>xxxxxxxx</endtime>
<type>online</type>
<key>LICENSE_KEY</key>
</license>离线许可证:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<license version="1">
<platform>windows</platform>
<starttime>xxxxxxxx</starttime>
<endtime>xxxxxxxx</endtime>
<key>LICENSE_KEY</key>
</license>license.xml 放在包根目录。PHP 示例直接将该 XML 文件路径传给 LibraryManager::licenseVerify(),您无需手动从 XML 中复制 <key> 的值。您可以使用以下方法进行离线认证:
<?php
// 加载示例自动加载器。
require __DIR__ . '/autoload.php';
use ComPDFKit\Conversion\LibraryManager;
use ComPDFKit\Conversion\ErrorCode;
// 验证许可证。Linux 示例包将 license.xml 放在包根目录,
// 并直接接受该 XML 路径。
$resourcePath = dirname(__DIR__);
$license = $resourcePath . '/license.xml';
$deviceId = '';
$appId = '';
$code = LibraryManager::licenseVerify($license, $deviceId, $appId);
if (!ErrorCode::isSuccess($code)) {
throw new RuntimeException('License verify failed: ' . ErrorCode::describe($code));
}
// 初始化转换资源。
LibraryManager::initialize($resourcePath);