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

Why Convert PDF to PowerPoint with PHP?

The pdfRest PDF to PowerPoint API Tool is a powerful service that allows developers to convert PDF documents into PowerPoint presentations programmatically. This tutorial will guide you through the process of sending an API call to the PDF to PowerPoint endpoint using PHP, which can be particularly useful in scenarios where you need to present data or reports that are originally in PDF format in a more interactive and editable PowerPoint format.

For instance, imagine you have a financial report in PDF that you want to discuss in a meeting. Using the API, you can quickly convert it to a PowerPoint presentation, allowing for easier navigation and the ability to highlight key points during your presentation.

PDF to PowerPoint with PHP Code Example

 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
];

$options = [
  'multipart' => [
    [
      'name' => 'file',
      'contents' => Utils::tryFopen('/path/to/file', 'r'),
      'filename' => '/path/to/file',
      'headers' => [
        'Content-Type' => ''
      ]
    ],
    [
      '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

Breaking Down the PHP Code

The code above performs the following actions:

  • Loads the required dependencies and classes.
  • Creates a new HTTP client instance.
  • Sets up the request headers, including the API key for authentication.
  • Configures the multipart request options, including the file to be converted and the output format.
  • Creates and sends an asynchronous POST request to the API endpoint.
  • Outputs the response, which is the converted PowerPoint file.

Each part of the multipart request is explained in detail below:

'Api-Key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

This is where you put your API key provided by pdfRest for authentication purposes.

'contents' => Utils::tryFopen('/path/to/file', 'r')

Opens the PDF file you want to convert. Replace '/path/to/file' with the actual file path.

'headers' => [
  'Content-Type' => ''
]

Set the correct 'Content-Type' for your file. For PDFs, this is typically 'application/pdf'.

'name' => 'output',
'contents' => 'pdfrest_powerpoint'

Specifies the desired output format. In this case, 'pdfrest_powerpoint' indicates that the output should be a PowerPoint file.

Beyond the Tutorial

By following the steps above, you've learned how to convert a PDF document to a PowerPoint presentation using PHP and the pdfRest API. This can be a great asset in automating document conversion 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.

Note: This is an example of a multipart API call. Code samples using JSON payloads can be found at GitHub.

Generate a self-service API Key now!

Create your FREE API Key to start processing PDFs in seconds, only possible with pdfRest.

Compare Plans
Contact Us