วิธีอัปเดต Doconut
ทำตามขั้นตอนเหล่านี้เพื่ออัปเดตจากเวอร์ชัน 1.0.5.2 หรือต่ำกว่า.
.NET เฟรมเวิร์ก 4.7
การกำหนดค่า Web.config
Viewer ต้องการให้ HttpHandler ถูกลงทะเบียนผ่านไฟล์ web.config ขึ้นอยู่กับเวอร์ชัน IIS ของคุณ สามารถทำได้โดยใช้ส่วนต่อไปนี้ที่กำหนดใน web.config.
ด้านล่าง IIS 7:
<httpHandlers>
<add verb="GET,POST" path="DocImage.axd" type="Doconut.DocImageHandler, Doconut" />
</httpHandlers>IIS 7 ขึ้นไป:
<handlers>
<add name="DocImage" verb="GET,POST" path="DocImage.axd" type="Doconut.DocImageHandler, Doconut" />
</handlers>อัปเดตการลงทะเบียนในหน้า ASPX
เปลี่ยนการลงทะเบียน assembly ในหน้า ASPX ของคุณ.
เก่า:
<%@ Register Assembly="DocumentViewer" Namespace="DotnetDaddy.DocumentViewer" TagPrefix="asp" %>ใหม่:
<%@ Register Assembly="Doconut" Namespace="Doconut" TagPrefix="asp" %>อัปเดตแท็กควบคุม
อัปเดตแท็กควบคุมจาก DocViewer เป็น Viewer.
เก่า:
<asp:DocViewer ID="ctlDoc" runat="server"/>ใหม่:
<asp:Viewer ID="ctlDoc" runat="server"/>อัปเดต Namespaces
Doconut 24.3.0 ได้เปลี่ยนชื่อ Namespaces เพิ่ม DLL ใหม่: Doconut.dll, Doconut.Formats.dll, Doconut.Configs.dll, และ Doconut.Clouds.dll.
Usings ใหม่:
using Doconut;
using Doconut.Configs;
using Doconut.Clouds;การเริ่มต้น:
var viewer = new Viewer();แพ็คเกจที่ต้องการ
- Newtonsoft.Json เวอร์ชัน 13.0.3
- System.Text.Encoding.CodePages เวอร์ชัน 6.0.0
- System.Text.Json เวอร์ชัน 6.0.0
.NET มาตรฐาน / คอร์
อัปเดต Namespaces
Doconut 24.3.0 ได้เปลี่ยนชื่อ Namespaces เพิ่ม DLL ใหม่: Doconut.dll, Doconut.Formats.dll, Doconut.Configs.dll, และ Doconut.Clouds.dll.
Usings ใหม่:
using Doconut;
using Doconut.Configs;
using Doconut.Clouds;การเริ่มต้น:
using System;
// อินสแตนซ์ Viewer ตอนนี้ได้รับจาก factory, DI container หรือผู้ให้บริการอื่น
// แทนที่การทำงานของ 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 หรือสูงกว่า
อัปเดต Namespaces
Doconut 24.3.0 ได้เปลี่ยนชื่อ Namespaces เพิ่ม DLL ใหม่: Doconut.dll, Doconut.Formats.dll, Doconut.Configs.dll, และ Doconut.Clouds.dll.
Usings ใหม่:
// การบูรณาการ .NET 6 ปัจจุบัน: Viewer มาจาก DI และการเปิดเอกสารเป็นแบบอะซิงโครนัส
var token = await viewer.OpenDocumentAsync(path, new PdfConfig { AllowSearch = true });การเริ่มต้น:
app.MapPost("/api/open", async (Viewer viewer) =>
{
// token เป็นแบบไม่โปร่งใส — ส่งให้ widget, อย่า log หรือ persist มัน.
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
หน้านี้เป็นประโยชน์หรือไม่?