Convert PowerPoint to PDF using File Conversion API in Ruby

Convert PowerPoint to PDF using File Conversion API in Ruby

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 PowerPoint presentations to PDF programmatically. In this article, we will learn how to convert PowerPoint to PDF using File Conversion API in Ruby.

The following topics shall be covered in this article:

PowerPoint to PDF Conversion REST API and Ruby SDK

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

gem install groupdocs_conversion_cloud

Please get your Client ID and Secret from the GroupDocs Dashboard before following the below mentioned steps. Once you have your Client ID and Client Secret, add these in the ruby application code as shown below:

Convert PowerPoint to PDF using REST API in Ruby

We will convert PowerPoint slides to PDF files by following the simple steps as given below. You can Upload the PowerPoint files to the Cloud using the code example. As a result, the uploaded PowerPoint slide will be available in the files section of the dashboard on the cloud. Now, let’s convert PPTX presentations to PDF documents programmatically by following the steps as 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 Ruby.

The above sample code will save the converted PDF file on the cloud. You can download converted PDF file using the following code example.

PPTX to PDF Conversion with Watermark using Ruby

We can convert PowerPoint presentations to PDF documents by adding 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 PPTX to PDF with watermark to the converted presentation using a REST API in Ruby. Please follow the steps mentioned earlier to upload and download files.

Convert Range of Pages from PPTX PDF to Ruby

We can convert a range of pages from PPTX presentations to PDF documents 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 Ruby.

Convert Specific Pages from PPTX to PDF in Ruby

We can convert specific pages of PPTX slides to PDF documents 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 PPTX to PDF using a REST API in Ruby.

Online PPTX to PDF Converter for Free

Please try the following free online PPTX conversion tool from any device with a modern browser like Chrome and Firefox. It has been developed using the Groupdocs.Conversion API.

Conclusion

In this article, we have learned how to convert PowerPoint presentation to PDF on the cloud. We have also seen how to convert specific pages or a range of pages from PPTX to PDF using Ruby. This article also explained how to programmatically upload a PPTX file to the cloud and then download the converted PDF 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.

Ask a question

If you have any questions about PPTX to DOCX Converter, please feel free to ask in GroupDocs.Conversion Forum and it will be answered within a few hours.

See Also