浏览我们的产品

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

安装

此包在 nuget.org 上提供,可通过包管理器控制台执行以下命令安装:

NuGet\Install-Package GroupDocs.viewer-Cloud

Version NuGet NuGet-GroupDocsCloud


要求

  • .NET Framework 2.0 或 .NET Standard 2.0
  • NuGet
  • 面向 .NET Framework 2.0 时需要 System.Web
  • GroupDocs Cloud 凭据 — 仪表板中的 Client ID and Client Secret

快速入门

获取 API 凭据

要使用 GroupDocs.Viewer Cloud,请在 GroupDocs.Cloud 仪表板 注册并获取 Client ID 和 Client Secret。

初始化 API

使用以下代码开始使用 GroupDocs.Viewer Cloud SDK for .NET。

using GroupDocs.Viewer.Cloud.Sdk.Api;
using GroupDocs.Viewer.Cloud.Sdk.Client;

string MyClientId = "YourClientId";
string MyClientSecret = "YourClientSecret";

var config = new Configuration(MyClientId, MyClientSecret);
config.ApiBaseUrl = "https://api.groupdocs.cloud";

var apiInstance = new ViewApi(config);

完整示例见 Constants.cs。

将本地文档转换为 JPEG

此示例将本地 Word 文档渲染为 JPEG,而不将其上传到云存储。

using System.IO;
using GroupDocs.Viewer.Cloud.Sdk.Api;
using GroupDocs.Viewer.Cloud.Sdk.Client;
using GroupDocs.Viewer.Cloud.Sdk.Model.Requests;

var config = new Configuration("YourClientId", "YourClientSecret");
config.ApiBaseUrl = "https://api.groupdocs.cloud";
var apiInstance = new ViewApi(config);

var response = apiInstance.ConvertAndDownload(new ConvertAndDownloadRequest("jpg", File.OpenRead("sample.docx")));
Console.WriteLine("ConvertAndDownload completed: " + response.Length + " bytes received");

完整示例见 ConvertAndDownload.cs。

渲染选定页面

此示例将 Word 文档的第 2 页和第 3 页渲染为 HTML。

using System.Collections.Generic;
using GroupDocs.Viewer.Cloud.Sdk.Api;
using GroupDocs.Viewer.Cloud.Sdk.Client;
using GroupDocs.Viewer.Cloud.Sdk.Model;
using GroupDocs.Viewer.Cloud.Sdk.Model.Requests;

var config = new Configuration("YourClientId", "YourClientSecret");
config.ApiBaseUrl = "https://api.groupdocs.cloud";
var apiInstance = new ViewApi(config);

var viewOptions = new ViewOptions
{
    FileInfo = new FileInfo { FilePath = "SampleFiles/sample.docx" },
    ViewFormat = ViewOptions.ViewFormatEnum.HTML,
    RenderOptions = new RenderOptions
    {
        PagesToRender = new List<int?> { 2, 3 }
    }
};

var response = apiInstance.CreateView(new CreateViewRequest(viewOptions));
Console.WriteLine("RenderSelectedPages completed: " + response.Pages.Count);

完整示例见 RenderSelectedPages.cs。

渲染受密码保护的文档

此示例将受密码保护的 Word 文档渲染为 HTML。

using GroupDocs.Viewer.Cloud.Sdk.Api;
using GroupDocs.Viewer.Cloud.Sdk.Client;
using GroupDocs.Viewer.Cloud.Sdk.Model;
using GroupDocs.Viewer.Cloud.Sdk.Model.Requests;

var config = new Configuration("YourClientId", "YourClientSecret");
config.ApiBaseUrl = "https://api.groupdocs.cloud";
var apiInstance = new ViewApi(config);

var viewOptions = new ViewOptions
{
    FileInfo = new FileInfo
    {
        FilePath = "SampleFiles/password_protected.docx",
        Password = "12345"
    },
    ViewFormat = ViewOptions.ViewFormatEnum.HTML
};

var response = apiInstance.CreateView(new CreateViewRequest(viewOptions));
Console.WriteLine("ViewProtectedDocument completed: " + response.Pages.Count);

完整示例见 ViewProtectedDocument.cs。

获取支持的文件格式

获取 viewer API 接受的格式。

using System.Linq;
using GroupDocs.Viewer.Cloud.Sdk.Api;
using GroupDocs.Viewer.Cloud.Sdk.Client;

var config = new Configuration("YourClientId", "YourClientSecret");
config.ApiBaseUrl = "https://api.groupdocs.cloud";
var apiInstance = new InfoApi(config);

var response = apiInstance.GetSupportedFileFormats();

foreach (var entry in response.Formats.Take(5))
{
    Console.WriteLine($"{entry.FileFormat}: {entry.Extension}");
}

完整示例见 GetSupportedFormats.cs。

GitHub 上的示例

GroupDocs.Viewer Cloud .NET Examples 仓库包含可直接运行的示例,涵盖:

CategoryExamples
渲染HTML、PDF 和图像输出; 选定页面; 水印; 受保护的文档
按格式CAD、电子邮件、PDF、电子表格、文本、Visio、文字处理、压缩包、Outlook、Project
Info文档信息、附件、支持的格式

如何运行示例

  1. 克隆或下载 示例仓库
  2. 在 Visual Studio 2017 或更高版本中打开 Examples/GroupDocs.Viewer.Cloud.Examples.CSharp.sln
  3. 右键单击解决方案并选择 Enable NuGet Package Restore
  4. 编辑 Examples/GroupDocs.Viewer.Cloud.Examples.CSharp/RunExamples.cs,设置 Constants.MyClientId 和 Constants.MyClientSecret
  5. 生成并运行

更多细节请参阅 Getting Started。


Product Docs Swagger Examples Blog Support Dashboard


标签

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


直接下载

 简体中文