Convert PDF to PowerPoint using REST API in Node.js

Convert PDF to PowerPoint using REST API in Node.js

PowerPoint is commonly used to present information in a series of separate pages or slides for group presentations within business organizations. In certain cases, you may need to convert PDF to PowerPoint presentations programmatically. In this article, we will learn how to convert PDF to PowerPoint using a REST API in Node.js.

The following topics shall be covered in this article:

PDF to PowerPoint Conversion REST API and Node.js SDK

For converting PDF to PPTX, we will be using the Node.js SDK of GroupDocs.Conversion Cloud API. Please install it using the following command in the console:

npm install groupdocs-conversion-cloud

Please get your Client ID and Secret from the dashboard before following the mentioned steps. Once you have your ID and secret, add in the code as shown below:

Convert PDF to PowerPoint using REST API in Node.js

We can convert PDF files into PowerPoint presentation slides by following the simple steps given below:

Upload the Document

Firstly, we will upload the PDF file to the Cloud using the code example given below:

As a result, the uploaded PDF file will be available in the files section of the dashboard on the cloud.

Convert PDF to PowerPoint in Node.js

We can convert PDF documents to PPTX presentations programmatically by following the steps given below:

  • Firstly, create an instance of the ConvertApi.
  • Next, create an instance of the ConvertSettings.
  • Then, set the input PDF file path.
  • And, assign “pptx” to format.
  • Also, provide the output file path.
  • After that, create ConvertDocumentRequest with ConvertSettings as argument.
  • Finally, call the ConvertApi.convertDocument() method with ConvertDocumentRequest.

The following code example shows how to convert a PDF document to a PPTX presentation using a REST API in Node.js.

Convert PDF to PowerPoint in Node.js
Convert PDF to PowerPoint in Node.js

Download PowerPoint Presentation

The above code sample will save the converted PPTX presentation file on the cloud. It can be downloaded using the following code example:

PDF to PPTX Conversion with Watermark using Node.js

We can convert PDF documents to PowerPoint presentations and add watermarks to converted PPTX presentations programmatically by following the steps given below:

  • Firstly, create an instance of the ConvertApi.
  • Now, create an instance of the ConvertSettings.
  • Then, set the input PDF file path.
  • And, assign “pptx” to format.
  • Also, provide the output file path.
  • Now, create an instance of the WatermarkOptions.
  • Then, set Watermark text, color, width, height, left, top, etc.
  • Now, define the PresentationConvertOptions and assign WatermarkOptions.
  • After that, create ConvertDocumentRequest with ConvertSettings as argument.
  • Finally, call the convertDocument() method with ConvertDocumentRequest.

The following code example shows how to convert a PDF to PPTX and add a watermark to the converted presentation using a REST API in Node.js. Please follow the steps mentioned earlier to upload and download files.

PDF to PPTX Conversion with Watermark using Node.js
PDF to PPTX Conversion with Watermark using Node.js

Convert Range of Pages from PDF to PPTX in Node.js

We can convert a range of pages from PDF documents to PPTX presentations programmatically by following the steps given below:

  • Firstly, create an instance of the ConvertApi.
  • Next, create an instance of the ConvertSettings.
  • Then, set the input PDF file path.
  • And, assign “pptx” to format.
  • Also, provide the output file path.
  • Next, create an instance of the PresentationConvertOptions.
  • Then, set a page range to convert from start page number as fromPage and total pages to convert as pagesCount.
  • After that, create ConvertDocumentRequest with ConvertSettings as argument.
  • Finally, call the ConvertApi.convertDocument() method with ConvertDocumentRequest.

The following code example shows how to convert a range of pages from PDF to PPTX using a REST API in Node.js.

Convert Specific Pages of PDF to PPTX in Node.js

We can convert specific pages of PDF documents to PPTX presentations programmatically by following the steps given below:

  • Firstly, create an instance of the ConvertApi.
  • Next, create an instance of the ConvertSettings.
  • Then, set the input PDF file path.
  • And, assign “pptx” to format.
  • Also, provide the output file path.
  • Next, create an instance of the PresentationConvertOptions.
  • Then, provide specific page numbers in a comma-separated array to convert.
  • After that, create ConvertDocumentRequest with ConvertSettings as argument.
  • Finally, call the ConvertApi.convertDocument() method with ConvertDocumentRequest.

The following code example shows how to convert specific pages from a PDF to PPTX using a REST API in Node.js.

PDF to PPTX Conversion without using Cloud Storage

We can convert PDF documents to PPTX presentations without using cloud storage by passing it in the request body and receiving the output file in the API response. Please follow the steps given below to convert a PDF to PPTX without using cloud storage.

  • Firstly, create an instance of the ConvertApi.
  • Next, read input PDF file from local path.
  • After that, create ConvertDocumentDirectRequest with output format and input file as arguments.
  • Finally, get results by calling the ConvertApi.convertDocumentDirect() method with ConvertDocumentDirectRequest.

The following code example shows how to convert a PDF document to a PPTX presentation without using cloud storage in Node.js.

Try Online

Please try the following free online PDF conversion tool, which is developed using the above API. https://products.groupdocs.app/conversion/

Conclusion

In this article, we have learned how to convert a PDF to PowerPoint presentation on the cloud. We have also seen how to convert specific pages or a range of pages from a PDF to PPTX using Node.js. This article also explained how to programmatically upload a PDF file to the cloud and then download the converted PPTX file from the Cloud. Besides, you can learn more about GroupDocs.Conversion Cloud API using the documentation. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser. In case of any ambiguity, please feel free to contact us on the forum.

See Also