HTML
JPG
PDF
XML
DOCX
PDF
如何使用云 .NET SDK 向 PDF 文档追加注释
为了通过云 .NET SDK 向 PDF 文档添加注释,我们将使用 Aspose.PDF Cloud .NET SDK 此云 SDK 允许您轻松构建基于云的 PDF 创建、编辑和转换应用程序,支持 C#、ASP.NET 或其他 .NET 语言,适用于各种云平台。打开 NuGet 包管理器,搜索 Aspose.PDF Cloud 并安装。您还可以从包管理器控制台使用以下命令。
包管理器控制台命令
PM> Install-Package Aspose.Pdf-Cloud
使用 .NET SDK 添加注释的步骤
Aspose.PDF Cloud 开发人员可以轻松地在短短几行代码中加载和追加注释到 PDF 文档。
- 上传 PDF 到云存储。
- 创建具有丰富元数据的绿色下划线注释。
- 将其应用于特定页面。
- 处理服务器响应。
- 下载更新后的文件。
此示例代码显示如何向 PDF 文档添加下划线注释
using Aspose.Pdf.Cloud.Sdk.Model;
namespace Annotations
{
public class NewUnderlineAnnotation
{
public static async Task Append(AnnotationsHelper helper, string documentName, int pageNumber, string outputName, string remoteFolder)
{
await helper.UploadFile(documentName);
List<UnderlineAnnotation> annotations = new List<UnderlineAnnotation>
{
new UnderlineAnnotation(
Name: "Underline_NEW_Annotation",
Rect: new Rectangle(100,350, 450,400),
Flags: new List<AnnotationFlags>() { AnnotationFlags.Default },
HorizontalAlignment: HorizontalAlignment.Left,
VerticalAlignment: VerticalAlignment.Top,
RichText: helper.config.NEW_UL_ANNOTATION_TEXT,
Subject: helper.config.NEW_UL_ANNOTATION_SUBJECT,
Contents: helper.config.NEW_UL_ANNOTATION_CONTENTS,
Title: helper.config.NEW_UL_ANNOTATION_DESCRIPTION,
ZIndex: 1,
Color: new Color(A: 0xFF, R: 0x00, G: 0xFF, B: 0x00),
QuadPoints: new List<Point>() {
new Point(X: 10, Y: 10),
new Point(X: 20, Y: 10),
new Point(X: 10, Y: 20),
new Point(X: 10, Y: 10)
},
Modified: "03/27/2025 00:00:00.000 AM"
)
};
AsposeResponse response = await helper.pdfApi.PostPageUnderlineAnnotationsAsync(documentName, pageNumber, annotations, folder: remoteFolder);
if (response == null)
Console.WriteLine("NewUnderlineAnnotation(): Unexpected error!");
else if (response.Code < 200 || response.Code > 299)
Console.WriteLine("NewUnderlineAnnotation(): Failed to append underline annotation to the document.");
else
{
Console.WriteLine("NewUnderlineAnnotation(): annotations '{0}' added to the document '{1}.", helper.config.NEW_UL_ANNOTATION_TEXT, documentName);
await helper.DownloadFile(documentName, outputName, "add_underline_annotation_");
}
}
}
}