Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-cloud/d199753de185202886f2d4fba6de1820 to your computer and use it in GitHub Desktop.
Save aspose-cloud/d199753de185202886f2d4fba6de1820 to your computer and use it in GitHub Desktop.
This Gist contains code snippets related to conversion DOCX to PDF and PDF to DOCX conversion in Ruby
This Gist contains code snippets related to conversion DOCX to PDF and PDF to DOCX conversion using Aspose.Words Cloud SDK for Ruby
require 'aspose_words_cloud'
# client credentials from https://dashboard.aspose.cloud/
client_id = "718e4235-8866-4ebe-bff4-f5a14a4b6466"
client_secret = "388e864b819d8b067a8b1cb625a2ea8e"
# associate Configuration properties with WordsApi
AsposeWordsCloud.configure do |config|
config.client_data['ClientId'] = client_id
config.client_data['ClientSecret'] = client_secret
end
# create an instance of WordsApi
@words_api = WordsAPI.new
# input DOCX file
fileName = "test_multi_pages.docx"
# resultant format
format = "pdf"
# Upload original document to Cloud Storage
@words_api.upload_file UploadFileRequest.new(File.new(fileName, 'rb'), fileName, nil)
# define document conversion parameters
request = ConvertDocumentRequest.new(File.new(fileName, 'rb'), format, nil, nil, nil, nil)
# initiate DOCX to PDF conversion process
result = @words_api.convert_document(request)
# print result response in console
puts("Result " + (result).to_s)
require 'aspose_words_cloud'
# client credentials from https://dashboard.aspose.cloud/
client_id = "718e4235-8866-4ebe-bff4-f5a14a4b6466"
client_secret = "388e864b819d8b067a8b1cb625a2ea8e"
# associate Configuration properties with WordsApi
AsposeWordsCloud.configure do |config|
config.client_data['ClientId'] = client_id
config.client_data['ClientSecret'] = secret
end
# create an instance of WordsApi
@words_api = WordsAPI.new
# input PDF file
fileName = "test_multi_pages.pdf"
# output format
format = "docx"
# name of resultant file
destName = "Out_test_multi_pages.docx"
# Upload original document to Cloud Storage
@words_api.upload_file UploadFileRequest.new(File.new(fileName, 'rb'), fileName, nil)
# create an instance of SaveAsRequest
request = SaveAsRequest.new(fileName, SaveOptionsData.new({:SaveFormat => format, :FileName => destName}), nil, nil, nil, nil, nil)
# initiate the conversion operation
result = @words_api.save_as(request)
# print the response of conversion
puts("Result " + (result).to_s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment