Skip to content

Commit 080955d

Browse files
Update README.md
1 parent fd8b8ba commit 080955d

File tree

1 file changed

+57
-16
lines changed

1 file changed

+57
-16
lines changed

README.md

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# GroupDocs.Conversion Cloud Ruby SDK
2-
Ruby gem for communicating with the GroupDocs.Conversion Cloud API
2+
3+
This repository contains GroupDocs.Conversion Cloud SDK for Ruby source code. This SDK has been developed to help you get started with using our document conversion REST API, allowing to seamlessly convert your documents to any format you need. With this single API, you can convert back and forth between over 50 types of documents and images, including all Microsoft Office and OpenDocument file formats, PDF documents, HTML, CAD, raster images and many more.
34

45
## Installation
56

@@ -11,32 +12,72 @@ gem install groupdocs_conversion_cloud
1112

1213
To add dependency to your app copy following into your Gemfile and run `bundle install`:
1314

15+
```ruby
16+
# Load the gem
17+
require 'groupdocs_conversion_cloud'
1418
```
15-
gem "groupdocs_conversion_cloud", "~> 25.6"
16-
```
19+
### Create an account
20+
Creating an account is very simple. Go to Dashboard to create a free account.
21+
We’re using Single Sign On across our websites, therefore, if you already have an account with our services, you can use it to also access the [Dashboard](https://dashboard.groupdocs.cloud).
22+
23+
### Create an API client app
24+
Before you can make any requests to GroupDocs Cloud API you need to get a Client Id and a Client Secret. This will be used to invoke GroupDocs Cloud API. You can get it by creating a new [Application](https://dashboard.groupdocs.cloud/applications).
1725

18-
## Getting Started
26+
## Convert document
1927

20-
Please follow the [installation](#installation) procedure and then run the following code:
2128
```ruby
2229
# Load the gem
2330
require 'groupdocs_conversion_cloud'
2431

25-
# Get your app_sid and app_key at https://dashboard.groupdocs.cloud (free registration is required).
26-
app_sid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
27-
app_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
32+
# Get your clientId and clientSecret at https://dashboard.groupdocs.cloud (free registration is required).
33+
client_id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
34+
client_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
2835

2936
# Create instance of the API class
30-
api = GroupDocsConversionCloud::InfoApi.from_keys(app_sid, app_key)
37+
apiInstance = GroupDocsConversionCloud::ConvertApi.from_keys(client_id, client_secret)
38+
39+
# Prepare request
40+
file = File.open("myFile.docx", "r")
41+
request = GroupDocsConversionCloud::ConvertDocumentDirectRequest.new("pdf", file)
42+
43+
# Convert
44+
result = apiInstance.convert_document_direct(request)
45+
46+
puts("Document converted: " + (result.length).to_s)
47+
```
48+
49+
## Convert document using cloud storage
50+
51+
```ruby
52+
# Load the gem
53+
require 'groupdocs_conversion_cloud'
54+
55+
# Get your clientId and clientSecret at https://dashboard.groupdocs.cloud (free registration is required).
56+
client_id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
57+
client_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
58+
59+
# Create instancea of the APIs
60+
fileApi = GroupDocsConversionCloud::FileApi.from_keys(client_id, client_secret)
61+
convertApi = GroupDocsConversionCloud::ConvertApi.from_keys(client_id, client_secret)
62+
63+
# Upload file
64+
file = File.open("myFile.docx", "r")
65+
fileApi.upload_file(GroupDocsConversionCloud::UploadFileRequest.new("myFile.docx", file))
66+
67+
# Convert
68+
settings = GroupDocsConversionCloud::ConvertSettings.new
69+
settings.file_path = "myFile.docx"
70+
settings.format = "pdf"
71+
settings.output_path = "converted"
72+
73+
result = convertApi.convert_document(GroupDocsConversionCloud::ConvertDocumentRequest.new(settings))
74+
75+
puts("Document converted: " + result[0].url)
3176

32-
# Retrieve supported converison types
33-
request = GroupDocsConversionCloud::GetSupportedConversionTypesRequest.new
34-
response = api.get_supported_conversion_types(request)
77+
# Download converted file
78+
response = fileApi.download_file(GroupDocsConversionCloud::DownloadFileRequest.new("converted/myFile.pdf", nil))
79+
puts("Expected response type is Stream: " + ($response).to_s)
3580

36-
# Print out supported conversion types
37-
puts("Supported file-formats:")
38-
response.each do |format|
39-
puts("#{format.source_format} to [#{format.target_formats.join(', ')}]")
4081
```
4182

4283
## Licensing

0 commit comments

Comments
 (0)