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 npmjs.com e pode ser instalado via npm executando o seguinte comando:

npm install groupdocs-viewer-cloud

NPM Version NPM Downloads NPM-GroupDocsCloud


Requisitos

Dependências

O SDK requer os seguintes pacotes:

PackageConstraint
axios1.8.4
form-data*
jsonwebtoken9.0.1
qs6.11.2

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 Node.js.

"use strict";
const viewer_cloud = require("groupdocs-viewer-cloud");

const clientId = "YourClientId";
const clientSecret = "YourClientSecret";

const config = new viewer_cloud.Configuration(clientId, clientSecret);
config.apiBaseUrl = "https://api.groupdocs.cloud";

const viewApi = viewer_cloud.ViewApi.fromConfig(config);

Veja o exemplo completo em RunExamples.js.

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.

"use strict";
const viewer_cloud = require("groupdocs-viewer-cloud");
const fs = require("fs");

const clientId = "YourClientId";
const clientSecret = "YourClientSecret";

const config = new viewer_cloud.Configuration(clientId, clientSecret);
config.apiBaseUrl = "https://api.groupdocs.cloud";

const viewApi = viewer_cloud.ViewApi.fromConfig(config);

(async () => {
    let format = "jpg";
    let filebuf = fs.readFileSync("./Resources/SampleFiles/sample.docx");
    let request = new viewer_cloud.ConvertAndDownloadRequest(format, filebuf);
    let response = await viewApi.convertAndDownload(request);
    console.log("ConvertAndDownload completed: " + response.length);
})();

Veja o exemplo completo em ConvertAndDownload.js.

Renderizar um documento em HTML responsivo

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

"use strict";
const viewer_cloud = require("groupdocs-viewer-cloud");

const clientId = "YourClientId";
const clientSecret = "YourClientSecret";

const config = new viewer_cloud.Configuration(clientId, clientSecret);
config.apiBaseUrl = "https://api.groupdocs.cloud";

const viewApi = viewer_cloud.ViewApi.fromConfig(config);

(async () => {
    let fileInfo = new viewer_cloud.FileInfo();
    fileInfo.filePath = "SampleFiles/sample.docx";
    let viewOptions = new viewer_cloud.ViewOptions();
    viewOptions.fileInfo = fileInfo;
    viewOptions.viewFormat = viewer_cloud.ViewOptions.ViewFormatEnum.HTML;
    viewOptions.renderOptions = new viewer_cloud.HtmlOptions();
    viewOptions.renderOptions.isResponsive = true;

    let request = new viewer_cloud.CreateViewRequest(viewOptions);
    let response = await viewApi.createView(request);
    console.log("HtmlViewerResponsiveLayout completed: " + response.pages.length);
})();

Veja o exemplo completo em HtmlViewerResponsiveLayout.js.

Renderizar páginas selecionadas

Este exemplo renderiza as páginas 2 e 3 de um documento em HTML.

"use strict";
const viewer_cloud = require("groupdocs-viewer-cloud");

const clientId = "YourClientId";
const clientSecret = "YourClientSecret";

const config = new viewer_cloud.Configuration(clientId, clientSecret);
config.apiBaseUrl = "https://api.groupdocs.cloud";

const viewApi = viewer_cloud.ViewApi.fromConfig(config);

(async () => {
    let fileInfo = new viewer_cloud.FileInfo();
    fileInfo.filePath = "SampleFiles/sample.docx";
    let viewOptions = new viewer_cloud.ViewOptions();
    viewOptions.fileInfo = fileInfo;
    viewOptions.viewFormat = viewer_cloud.ViewOptions.ViewFormatEnum.HTML;
    viewOptions.renderOptions = new viewer_cloud.HtmlOptions();
    viewOptions.renderOptions.pagesToRender = [2, 3];

    let request = new viewer_cloud.CreateViewRequest(viewOptions);
    let response = await viewApi.createView(request);
    console.log("RenderSelectedPages completed: " + response.pages.length);
})();

Veja o exemplo completo em RenderSelectedPages.js.

Exibir um documento protegido por senha

Este exemplo renderiza um documento do Word protegido por senha em HTML.

"use strict";
const viewer_cloud = require("groupdocs-viewer-cloud");

const clientId = "YourClientId";
const clientSecret = "YourClientSecret";

const config = new viewer_cloud.Configuration(clientId, clientSecret);
config.apiBaseUrl = "https://api.groupdocs.cloud";

const viewApi = viewer_cloud.ViewApi.fromConfig(config);

(async () => {
    let fileInfo = new viewer_cloud.FileInfo();
    fileInfo.filePath = "SampleFiles/password_protected.docx";
    fileInfo.password = "12345";
    let viewOptions = new viewer_cloud.ViewOptions();
    viewOptions.fileInfo = fileInfo;
    viewOptions.viewFormat = viewer_cloud.ViewOptions.ViewFormatEnum.HTML;

    let request = new viewer_cloud.CreateViewRequest(viewOptions);
    let response = await viewApi.createView(request);
    console.log("ViewProtectedDocument completed: " + response.pages.length);
})();

Veja o exemplo completo em ViewProtectedDocument.js.

Obter os formatos de visualização compatíveis

Recupere os formatos de documento que a API pode renderizar.

"use strict";
const viewer_cloud = require("groupdocs-viewer-cloud");

const clientId = "YourClientId";
const clientSecret = "YourClientSecret";

const config = new viewer_cloud.Configuration(clientId, clientSecret);
config.apiBaseUrl = "https://api.groupdocs.cloud";

const infoApi = viewer_cloud.InfoApi.fromConfig(config);

(async () => {
    let response = await infoApi.getSupportedFileFormats();
    console.log("Formats count: " + response.formats.length);
})();

Veja o exemplo completo em GetSupportedFormats.js.

Exemplos no GitHub

O repositório GroupDocs.Viewer Cloud Node.js 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.js e defina clientId e clientSecret
  3. Vá para o diretório Examples
  4. Execute npm install
  5. Execute npm update
  6. Execute npm run-script start

Para mais detalhes, visite Getting Started.


Product Docs Swagger Examples Blog Support Dashboard


Tags

Document Rendering API | Node.js 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