How to Convert PDF to PowerPoint PPTX in PHP

Cloudmersive
1 min readMay 3, 2024

Writing PHP code to convert PDFs to presentation formats like PowerPoint can be a bit of a challenge.

Thankfully, we can save some time and effort by calling a free PDF to PowerPoint conversion API with complementary, ready-to-run PHP code examples.

We can start by installing the PHP client via Composer. Let’s execute the below command from our command line:

composer require cloudmersive/cloudmersive_document_convert_api_client

Next, we can turn our attention to API authorization. We can grab a free Cloudmersive API key to make up to 800 conversions per month with zero additional commitments.

With our API copied to our clipboard, we can now call the function and make our PDF to PowerPoint conversion:

<?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;
}
?>

That’s all there is to it! We can write the resulting PPTX encoding to a new file and begin working on our PowerPoint presentation right after.

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.