How to Convert PDF to PowerPoint with PHP

Learn how to use PHP to call the PDF to PowerPoint API Tool from pdfRest and quickly turn your PDF formatted documents into PowerPoint files.
Share this page

The pdfRest PDF to PowerPoint API Tool is a powerful service that allows developers to convert PDF documents into editable PowerPoint presentations. This is particularly useful in scenarios where you need to present data or reports that are originally in a PDF format in a more dynamic, editable format.

For instance, imagine you have a financial report in PDF that you want to discuss in a meeting. Using this API, you can quickly convert it to a PowerPoint presentation, allowing for easier navigation and the ability to highlight key points. This tutorial will guide you through the process of sending an API call to the PDF to PowerPoint endpoint using PHP.

PDF to PowerPoint with PHP Code Example

require 'vendor/autoload.php';

use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Utils;

$client = new Client();

$headers = [
  'Api-Key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
];

$options = [
  'multipart' => [
    [
      'name' => 'file',
      'contents' => Utils::tryFopen('/path/to/file', 'r'),
      'filename' => 'example.pdf',
      'headers' => [
        'Content-Type' => 'application/pdf'
      ]
    ],
    [
      'name' => 'output',
      'contents' => 'pdfrest_powerpoint'
    ]
  ]
];

$request = new Request('POST', 'https://api.pdfrest.com/powerpoint', $headers);

$res = $client->sendAsync($request, $options)->wait();

echo $res->getBody();

Source: GitHub

Understanding the Code

The PHP script above is a straightforward example of converting a PDF to a PowerPoint file using the pdfRest API. It is configured to send your PDF as a multipart request, specifying the desired output format.

  • The 'Api-Key' is required in the headers for authentication.
  • The 'name' => 'file' part of the request handles the PDF document itself, with Utils::tryFopen opening the file from your server.
  • The crucial 'name' => 'output' parameter is set to 'pdfrest_powerpoint', which explicitly tells the API to execute the PDF to PowerPoint conversion.
  • The request is sent to the https://api.pdfrest.com/powerpoint endpoint, which is solely for this conversion task.

Frequently Asked Questions

Below are some common questions about converting PDFs to PowerPoint.

Does the conversion maintain the original formatting and images?
The conversion strives to maintain the original layout as closely as possible, including text, fonts, and images. However, due to the different nature of PDF and PowerPoint formats, some minor adjustments may be needed to achieve a pixel-perfect result.
What happens to complex PDF elements like tables or charts?
The API will convert tables, charts, and other graphical elements from the PDF and place them as editable objects within the PowerPoint file. The goal is to provide a fully editable presentation rather than just a static image.
Can I convert a password-protected PDF?
The PDF to PowerPoint API Tool cannot directly process a password-protected document. To convert a protected PDF, you must first remove the password using the Encrypt PDF API Tool, which supports adding and removing passwords.

What's Next?

You have now successfully converted a PDF to an editable PowerPoint presentation using PHP. This functionality can be a great asset in automating document workflows within your applications. You are encouraged to explore all of the pdfRest API Tools in the API Lab and refer to the API Reference documentation for more details on how to use the various features provided by the service.

Generate a self-service API Key now!
Create your FREE API Key to start processing PDFs in seconds, only possible with pdfRest.