Skip to content

Commit 095a7a5

Browse files
Update README.md
1 parent e81f662 commit 095a7a5

1 file changed

Lines changed: 50 additions & 16 deletions

File tree

README.md

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
# GroupDocs.Viewer Cloud Ruby SDK
2-
Ruby gem for communicating with the GroupDocs.Viewer Cloud API
2+
Ruby gem for communicating with the GroupDocs.Viewer Cloud API. This SDK allows you to work with GroupDocs.Viewer Cloud REST APIs in your Ruby applications, enabling you to render documents in HTML, image, or PDF format with the flexibility to render the whole document or a custom range of pages.
3+
4+
## Requirements
5+
6+
Ruby 2.4+
37

48
## Installation
59

6-
A gem of groupdocs_viewer_cloud is available at [rubygems.org](https://rubygems.org). You can install it with:
10+
Install `groupdocs_viewer_cloud` from [RubyGems](https://rubygems.org):
711

8-
```shell
12+
```sh
913
gem install groupdocs_viewer_cloud
10-
```
14+
```
1115

12-
To add dependency to your app copy following into your Gemfile and run `bundle install`:
16+
Or add the dependency to your Gemfile and run `bundle install`:
1317

14-
```
18+
```ruby
1519
gem "groupdocs_viewer_cloud", "~> 25.7"
1620
```
1721

1822
## Getting Started
1923

20-
Please follow the [installation](#installation) procedure and then run the following code:
24+
Please follow the [installation procedure](#installation) and then run the following code:
25+
2126
```ruby
2227
# Load the gem
2328
require 'groupdocs_viewer_cloud'
@@ -27,16 +32,45 @@ app_sid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
2732
app_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
2833

2934
# Create instance of the API class
30-
api = GroupDocsViewerCloud::InfoApi.from_keys(app_sid, app_key)
35+
api_instance = GroupDocsViewerCloud::ViewApi.from_keys(app_sid, app_key)
36+
37+
format = "jpg"
38+
file = File.open("myfile.txt", "r")
39+
40+
request = GroupDocsViewerCloud::ConvertAndDownloadRequest.new(format, file)
41+
42+
response = api_instance.convert_and_download(request)
43+
```
44+
45+
Below is an example demonstrating how to upload a document, render it, and download the result using GroupDocs.Viewer Cloud SDK for Ruby:
46+
47+
```ruby
48+
require 'groupdocs_viewer_cloud'
49+
50+
app_sid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
51+
app_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
52+
53+
# Upload input file to cloud storage
54+
file_api_instance = GroupDocsViewerCloud::FileApi.from_keys(app_sid, app_key)
55+
upload_request = GroupDocsViewerCloud::UploadFileRequest.new("myfile.txt", "C:\\Data\\myfile.txt")
56+
file_api_instance.upload_file(upload_request)
57+
58+
# Render to html format
59+
view_api_instance = GroupDocsViewerCloud::ViewApi.from_keys(app_sid, app_key)
60+
view_options = GroupDocsViewerCloud::ViewOptions.new
61+
view_options.file_info = GroupDocsViewerCloud::FileInfo.new
62+
view_options.file_info.file_path = "myfile.txt"
63+
view_options.view_format = "HTML"
64+
view_options.output_path = "myfile.html"
65+
66+
create_view_request = GroupDocsViewerCloud::CreateViewRequest.new(view_options)
67+
view_api_instance.create_view(create_view_request)
3168

32-
# Retrieve supported file-formats
33-
response = api.get_supported_file_formats
69+
# Download result
70+
download_request = GroupDocsViewerCloud::DownloadFileRequest.new("myfile.html")
71+
response = file_api_instance.download_file(download_request)
3472

35-
# Print out supported file-formats
36-
puts("Supported file-formats:")
37-
response.formats.each do |format|
38-
puts("#{format.file_format} (#{format.extension})")
39-
end
73+
puts("Expected response type is Stream: #{response.size}")
4074
```
4175

4276
## Licensing
@@ -50,4 +84,4 @@ GroupDocs.Viewer Cloud Ruby SDK licensed under [MIT License](LICENSE).
5084
+ [**Blog**](https://blog.groupdocs.cloud/category/viewer)
5185

5286
## Contact Us
53-
Your feedback is very important to us. Please feel free to contact us using our [Support Forums](https://forum.groupdocs.cloud/c/viewer).
87+
Your feedback is very important to us. Please feel free to contact us

0 commit comments

Comments
 (0)