If so you can download any of the below versions for testing. The product will function as normal except for an evaluation limitation. At the time of purchase we provide a license file via email that will allow the product to work in its full capacity. If you would also like an evaluation license to test without any restrictions for 30 days, please follow the directions provided here.
If you experience errors, when you try to download a file, make sure your network policies (enforced by your company or ISP) allow downloading ZIP and/or MSI files.

安装
该软件包在 rubygems.org 可用,可通过执行以下命令使用 gem 安装:
gem install groupdocs_viewer_cloud

要求
依赖项
SDK 需要以下 gem:
| Package | Constraint |
|---|
| addressable | ~> 2.8.0, >= 2.8.0 |
| faraday | ~> 0.14.0 |
快速入门
获取 API 凭证
要使用 GroupDocs.Viewer Cloud,请在 GroupDocs.Cloud Dashboard 注册并获取 Client ID 和 Client Secret。
初始化 API
使用以下代码开始使用 GroupDocs.Viewer Cloud SDK for Ruby。
require 'groupdocs_viewer_cloud'
# Get your client id and client secret at https://dashboard.groupdocs.cloud
client_id = "YourClientId"
client_secret = "YourClientSecret"
config = GroupDocsViewerCloud::Configuration.new(client_id, client_secret)
config.api_base_url = "https://api.groupdocs.cloud"
apiInstance = GroupDocsViewerCloud::ViewApi.from_config(config)
请参阅 RunExamples.rb 中的完整示例。
转换并下载文档
初始化后,使用此基本示例将本地文档渲染为 JPG,而不上传到云存储。
require 'groupdocs_viewer_cloud'
client_id = "YourClientId"
client_secret = "YourClientSecret"
config = GroupDocsViewerCloud::Configuration.new(client_id, client_secret)
config.api_base_url = "https://api.groupdocs.cloud"
apiInstance = GroupDocsViewerCloud::ViewApi.from_config(config)
format = "jpg"
file = File.open("Resources/SampleFiles/sample.docx", "r")
request = GroupDocsViewerCloud::ConvertAndDownloadRequest.new format, file
response = apiInstance.convert_and_download(request)
puts("ConvertAndDownload completed: " + response.length.to_s)
请参阅 ConvertAndDownload.rb 中的完整示例。
将文档渲染为响应式 HTML
此示例创建具有响应式布局的 HTML 视图。
require 'groupdocs_viewer_cloud'
client_id = "YourClientId"
client_secret = "YourClientSecret"
config = GroupDocsViewerCloud::Configuration.new(client_id, client_secret)
config.api_base_url = "https://api.groupdocs.cloud"
apiInstance = GroupDocsViewerCloud::ViewApi.from_config(config)
viewOptions = GroupDocsViewerCloud::ViewOptions.new
viewOptions.file_info = GroupDocsViewerCloud::FileInfo.new
viewOptions.file_info.file_path = "SampleFiles/sample.docx"
viewOptions.view_format = "HTML"
viewOptions.render_options = GroupDocsViewerCloud::HtmlOptions.new
viewOptions.render_options.is_responsive = true
request = GroupDocsViewerCloud::CreateViewRequest.new(viewOptions)
response = apiInstance.create_view(request)
puts("HtmlViewerResponsiveLayout completed: " + response.pages.length.to_s)
请参阅 HtmlViewerResponsiveLayout.rb 中的完整示例。
渲染选定页面
此示例将文档的第 2 页和第 3 页渲染为 HTML。
require 'groupdocs_viewer_cloud'
client_id = "YourClientId"
client_secret = "YourClientSecret"
config = GroupDocsViewerCloud::Configuration.new(client_id, client_secret)
config.api_base_url = "https://api.groupdocs.cloud"
apiInstance = GroupDocsViewerCloud::ViewApi.from_config(config)
viewOptions = GroupDocsViewerCloud::ViewOptions.new
viewOptions.file_info = GroupDocsViewerCloud::FileInfo.new
viewOptions.file_info.file_path = "SampleFiles/sample.docx"
viewOptions.view_format = "HTML"
viewOptions.render_options = GroupDocsViewerCloud::HtmlOptions.new
viewOptions.render_options.pages_to_render = [2, 3]
request = GroupDocsViewerCloud::CreateViewRequest.new(viewOptions)
response = apiInstance.create_view(request)
puts("RenderSelectedPages completed: " + response.pages.length.to_s)
请参阅 RenderSelectedPages.rb 中的完整示例。
查看受密码保护的文档
此示例将受密码保护的 Word 文档渲染为 HTML。
require 'groupdocs_viewer_cloud'
client_id = "YourClientId"
client_secret = "YourClientSecret"
config = GroupDocsViewerCloud::Configuration.new(client_id, client_secret)
config.api_base_url = "https://api.groupdocs.cloud"
apiInstance = GroupDocsViewerCloud::ViewApi.from_config(config)
viewOptions = GroupDocsViewerCloud::ViewOptions.new
viewOptions.file_info = GroupDocsViewerCloud::FileInfo.new
viewOptions.file_info.file_path = "SampleFiles/password_protected.docx"
viewOptions.file_info.password = "12345"
viewOptions.view_format = "HTML"
request = GroupDocsViewerCloud::CreateViewRequest.new(viewOptions)
response = apiInstance.create_view(request)
puts("ViewProtectedDocument completed: " + response.pages.length.to_s)
请参阅 ViewProtectedDocument.rb 中的完整示例。
获取支持的查看格式
获取 API 可以渲染的文档格式。
require 'groupdocs_viewer_cloud'
client_id = "YourClientId"
client_secret = "YourClientSecret"
config = GroupDocsViewerCloud::Configuration.new(client_id, client_secret)
config.api_base_url = "https://api.groupdocs.cloud"
infoApi = GroupDocsViewerCloud::InfoApi.from_config(config)
result = infoApi.get_supported_file_formats()
puts("Formats count: " + result.formats.length.to_s)
请参阅 GetSupportedFormats.rb 中的完整示例。
GitHub 上的示例
GroupDocs.Viewer Cloud Ruby Examples 仓库包含可直接运行的示例,涵盖:
| Category | Examples |
|---|
| Basic Usage | 转换并下载, HTML 查看器, 图像查看器, PDF 查看器, 文档信息, 附件, 支持的格式 |
| Rendering Options | 选定页面, 连续页面, 水印, 笔记, 评论, 自定义字体 |
| Loading Options | 受密码保护的文档, 编码 |
| File Types | 压缩文件, CAD, 电子邮件, PDF, 电子表格, Visio, Word, Outlook 和项目文件 |
如何运行示例
- 克隆或下载示例仓库
- 编辑
Examples/RunExamples.rb 并设置 client_id 和 client_secret - 进入
Examples 目录 - 运行
gem install groupdocs_viewer_cloud - 执行
ruby RunExamples.rb
更多详情请访问 Getting Started。

Document Rendering API | Ruby Cloud API | GroupDocs.Viewer Cloud | REST API | HTML Rendering | PDF Conversion | Image Rendering | Document Viewing | Multi-Page Rendering | Document Streaming | CAD Rendering | E-Mail Message Rendering | Visio Rendering | MS Project Rendering | Outlook Data Rendering | Spreadsheet Rendering | Word Processing Rendering | Custom View Options | Responsive HTML | Attachment Rendering | Secure API Access | Cloud Storage Integration