应用许可证密钥
如果您还没有获取许可证密钥,请查看如何获取许可证密钥。
ComPDF Conversion SDK 目前支持通过离线认证验证许可证密钥。
了解:
复制许可证密钥
正确获取许可证密钥,是许可证应用的关键。
- 在您收到的邮件中,找到包含许可证密钥的 XML 文件。
- 打开 XML 文件,通过
<type>字段判断许可证类型。如果是<type>online</type>则为在线许可证,<type>offline</type>或无该字段则为离线许可证。
在线许可证:
xml
<?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
<?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>- 示例包将 XML 文件作为
license.xml放在包根目录。PHP 示例直接将该 XML 文件路径传给LibraryManager::licenseVerify(),您无需手动从 XML 中复制<key>的值。
应用许可证密钥
您可以使用以下方法进行离线认证:
php
<?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);