如何在PHP中将PDF转换为PowerPoint PPTX

软文推广2周前发布 刘老三
8 0

值得庆幸的是,我们可以通过调用免费的 PDF 到 PowerPoint 转换 API 以及补充的、可立即运行的 PHP 代码示例来节省一些时间和精力。

如何在PHP中将PDF转换为PowerPoint PPTX

我们可以从通过 Composer 安装 PHP 客户端开始。让我们从命令行执行以下命令:

composer require cloudmersive/cloudmersive_document_convert_api_client

接下来我们可以把注意力转向API授权。我们可以获得免费的 Cloudmersive API 密钥,每月可进行多达 800 次转化,且额外承诺为零。

将 API 复制到剪贴板后,我们现在可以调用该函数并将 PDF 转换为 PowerPoint:

<?php
require_once(__DIR__ . ‘/vendor/autoload.php’);

// Configure API key authorization: Apikey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey(‘Apikey’, ‘YOUR_API_KEY’);

$apiInstance = new Swagger\Client\Api\ConvertDocumentApi(

new GuzzleHttp\Client(),
$config
);
$input_file = “/path/to/inputfile”; // \SplFileObject | Input file to perform the operation on.

try {
$result = $apiInstance->convertDocumentPdfToPptx($input_file);
print_r($result);
} catch (Exception $e) {
echo ‘Exception when calling ConvertDocumentApi->convertDocumentPdfToPptx: ‘, $e->getMessage(), PHP_EOL;
}
?>

这里的所有都是它的!我们可以将生成的 PPTX 编码写入一个新文件,然后立即开始处理 PowerPoint 演示文稿。

© 版权声明

相关文章