How to Convert a PPTX Presentation to a PNG Image Array using PHP
While PowerPoint offers excellent customization features for creating presentations, thumbnails, and other forms of important content, PPTX files are always on the bulky side, making them less than ideal for sharing across networks. Thankfully, converting a PPTX document to a PNG array is an easy solution to this problem: this operation yields a lightweight, static alternative to PPTX files which can be shared and opened virtually anywhere.
Using the brief, ready-to-run code examples provided below, you can easily implement a PPTX to PNG conversion API into your PHP applications. To use this solution for free, simply register a free account on our website and include your free-tier API key in your request (free accounts yield a limit of 800 API calls per month with no hidden commitments).
To call this API, let’s start by installing the SDK with the following command:
composer require cloudmersive/cloudmersive_document_convert_api_client
After that, let’s call the function, including our API key in the $config field:
<?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->convertDocumentPptxToPng($input_file);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ConvertDocumentApi->convertDocumentPptxToPng: ', $e->getMessage(), PHP_EOL;
}
?>
Just like that, you’re all done. Enjoy your low-code, scalable document conversion solution!