如何更新 Doconut
按照以下步骤将 Doconut 从 1.0.5.2 版本或以下更新到最新版本。
.NET Framework 4.7
Web.config 配置
查看器需要通过 web.config 文件注册 HttpHandler。根据您的 IIS 版本,可以使用以下在 web.config 中定义的段落进行注册。
IIS 7 以下:
xml
<httpHandlers>
<add verb="GET,POST" path="DocImage.axd" type="Doconut.DocImageHandler, Doconut" />
</httpHandlers>IIS 7 及以上:
xml
<handlers>
<add name="DocImage" verb="GET,POST" path="DocImage.axd" type="Doconut.DocImageHandler, Doconut" />
</handlers>更新 ASPX 页面中的注册
更改您 ASPX 页面中的程序集注册。
旧:
aspx
<%@ Register Assembly="DocumentViewer" Namespace="DotnetDaddy.DocumentViewer" TagPrefix="asp" %>新:
aspx
<%@ Register Assembly="Doconut" Namespace="Doconut" TagPrefix="asp" %>更新控件标签
将控件标签从 DocViewer 更新为 Viewer。
旧:
aspx
<asp:DocViewer ID="ctlDoc" runat="server"/>新:
aspx
<asp:Viewer ID="ctlDoc" runat="server"/>更新命名空间
Doconut 24.3.0 重命名了命名空间。添加新的 DLL:Doconut.dll、Doconut.Formats.dll、Doconut.Configs.dll 和 Doconut.Clouds.dll。
新的 Usings:
csharp
using Doconut;
using Doconut.Configs;
using Doconut.Clouds;初始化:
csharp
var viewer = new Viewer();包依赖
- Newtonsoft.Json 13.0.3(包)
- System.Text.Encoding.CodePages 6.0.0(包)
- System.Text.Json 6.0.0(包)
.NET Standard / Core
更新命名空间
Doconut 24.3.0 重命名了命名空间。添加新的 DLL:Doconut.dll、Doconut.Formats.dll、Doconut.Configs.dll 和 Doconut.Clouds.dll。
新的 Usings:
csharp
using Doconut;
using Doconut.Configs;
using Doconut.Clouds;初始化:
csharp
using System;
// Viewer 实例现在是从工厂、DI 容器或其他提供者获取的。
// 将 GetViewer 的实现替换为实际的获取逻辑。
Viewer GetViewer() => throw new NotImplementedException();
var viewer = GetViewer(); // 获取 Viewer 实例包依赖
- Microsoft.Extensions.Caching.Abstractions 3.1.10(包)
- SkiaSharp 2.88.6(包)
- Newtonsoft.Json 13.0.3(包)
- System.Drawing.Common 6.0.0(包)
- System.Text.Json 6.0.0(包)
- System.Text.Encoding.CodePages 7.0.0(包)
.NET 6 或更高
更新命名空间
Doconut 24.3.0 重命名了命名空间。添加新的 DLL:Doconut.dll、Doconut.Formats.dll、Doconut.Configs.dll 和 Doconut.Clouds.dll。
新的 Usings:
csharp
// 当前 .NET 6 集成:Viewer 来自 DI,文档打开是异步的。
var token = await viewer.OpenDocumentAsync(path, new PdfConfig { AllowSearch = true });初始化:
csharp
app.MapPost("/api/open", async (Viewer viewer) =>
{
// 该令牌是不可见的 — 将其交给小部件,切勿记录或持久化。
string token = await viewer.OpenDocumentAsync("wwwroot/files/Sample.pdf");
return Results.Ok(new { token });
});包依赖
- Microsoft.Extensions.Caching.Abstractions 3.1.10(包)
- Newtonsoft.Json 13.0.3(包)
- SkiaSharp 2.88.6(包)
- System.Drawing.Common 7.0.0(包)
- System.Text.Encoding.CodePages 7.0.0(包)
此页面对您有帮助吗?