How to convert PowerPoint PPTX to PDF in Ruby
1 min readAug 9, 2019
The title speaks for itself, so let’s dive straight in. First, add the Convert API Client to your Gemfile.
gem 'cloudmersive-convert-api-client', '~> 1.3.3'
Then call convert_document_autodetect_to_pdf, as follows:
# load the gem
require 'cloudmersive-convert-api-client'
# setup authorization
CloudmersiveConvertApiClient.configure do |config|
# Configure API key authorization: Apikey
config.api_key['Apikey'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
#config.api_key_prefix['Apikey'] = 'Bearer'
endapi_instance = CloudmersiveConvertApiClient::ConvertDocumentApi.newinput_file = File.new("/path/to/file") # File | Input file to perform the operation on.begin
#Convert Document to PDF
result = api_instance.convert_document_autodetect_to_pdf(input_file)
p result
rescue CloudmersiveConvertApiClient::ApiError => e
puts "Exception when calling ConvertDocumentApi->convert_document_autodetect_to_pdf: #{e}"
end
And you’re done! Simple right? Note that this function is not limited to PowerPoint files, covering virtually any format you desire.