Navegue pelos nossos produtos

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.


Product Docs Swagger Examples Blog Support Dashboard

Instalação

O pacote está disponível em rubygems.org e pode ser instalado via gem executando o seguinte comando:

gem install groupdocs_viewer_cloud

Gem Version Gem Total Downloads Ruby-GroupDocsCloud


Requisitos

Dependências

O SDK requer as seguintes gems:

PackageConstraint
addressable~> 2.8.0, >= 2.8.0
faraday~> 0.14.0

Início rápido

Obtenha suas credenciais de API

Para usar o GroupDocs.Viewer Cloud, cadastre-se no GroupDocs.Cloud Dashboard e obtenha seu Client ID e Client Secret.

Inicialize a API

Use o código a seguir para começar a usar o 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)

Veja o exemplo completo em RunExamples.rb.

Converter e baixar um documento

Depois de inicializada, use este exemplo básico para renderizar um documento local em JPG sem enviá-lo para o armazenamento na nuvem.

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)

Veja o exemplo completo em ConvertAndDownload.rb.

Renderizar um documento em HTML responsivo

Este exemplo cria uma visualização HTML com um layout responsivo.

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)

Veja o exemplo completo em HtmlViewerResponsiveLayout.rb.

Renderizar páginas selecionadas

Este exemplo renderiza as páginas 2 e 3 de um documento em 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)

Veja o exemplo completo em RenderSelectedPages.rb.

Exibir um documento protegido por senha

Este exemplo renderiza um documento do Word protegido por senha em 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)

Veja o exemplo completo em ViewProtectedDocument.rb.

Obter os formatos de visualização compatíveis

Recupere os formatos de documento que a API pode renderizar.

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)

Veja o exemplo completo em GetSupportedFormats.rb.

Exemplos no GitHub

O repositório GroupDocs.Viewer Cloud Ruby Examples inclui exemplos prontos para executar que abrangem:

CategoryExamples
Basic UsageConverter e baixar, visualizador HTML, visualizador de imagens, visualizador PDF, informações do documento, anexos, formatos compatíveis
Rendering OptionsPáginas selecionadas, páginas consecutivas, marcas d’água, notas, comentários, fontes personalizadas
Loading OptionsDocumentos protegidos por senha, codificação
File TypesArquivo compactado, CAD, e-mail, PDF, planilha, Visio, Word, Outlook e arquivos de projeto

Como executar os exemplos

  1. Clone ou baixe o repositório de exemplos
  2. Edite Examples/RunExamples.rb e defina client_id e client_secret
  3. Vá para o diretório Examples
  4. Execute gem install groupdocs_viewer_cloud
  5. Execute ruby RunExamples.rb

Para mais detalhes, visite Getting Started.


Product Docs Swagger Examples Blog Support Dashboard


Tags

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



 Português