HTML JPG PDF XML DOCX
  Product Family
PDF

通过 .NET SDK 向 PDF 添加删除线注释

用于向 PDF 文档添加注释的 .NET API。

Get Started

如何使用 Cloud .NET SDK 向 PDF 文档追加注释

为了通过 Cloud .NET SDK 向 PDF 文档添加删除线注释,我们将使用 Aspose.PDF Cloud .NET SDK 这个 Cloud SDK 允许您轻松构建基于云的 PDF 创建、编辑和转换应用程序,支持 C#、ASP.NET 或其他 .NET 语言,适用于各种云平台。打开 NuGet 包管理器,搜索 Aspose.PDF Cloud 并安装。您也可以使用以下命令从包管理器控制台安装。

包管理器控制台命令


    PM> Install-Package Aspose.Pdf-Cloud
     

使用 .NET SDK 添加注释的步骤

Aspose.PDF Cloud 开发人员可以轻松地在几行代码中加载和追加注释到 PDF 文档。

  1. 上传输入 PDF。
  2. 创建具有位置、颜色和文本等属性的新 StrikeOutAnnotation。
  3. 使用 Aspose.PDF Cloud API 将其添加到所需页面。
  4. 验证响应。
  5. 本地下载更新后的文档。
 

此示例代码展示了如何向 PDF 文档添加注释


    using Aspose.Pdf.Cloud.Sdk.Model;

    namespace Annotations
    {
        public class NewStrikeoutAnnotation
        {
            public static async Task Append(AnnotationsHelper helper, string documentName, int pageNumber, string outputName, string remoteFolder)
            {
                await helper.UploadFile(documentName);

                List<StrikeOutAnnotation> annotations = new List<StrikeOutAnnotation>
                {
                    new StrikeOutAnnotation(
                        Name: "Strikeout_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_SO_ANNOTATION_TEXT,
                        Subject: helper.config.NEW_SO_ANNOTATION_SUBJECT,
                        Contents: helper.config.NEW_SO_ANNOTATION_CONTENTS,
                        Title: helper.config.NEW_SO_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.PostPageStrikeOutAnnotationsAsync(documentName, pageNumber, annotations, folder: remoteFolder);

                if (response == null)
                    Console.WriteLine("NewStrikeoutAnnotation(): Unexpected error!");
                else if (response.Code < 200 || response.Code > 299)
                    Console.WriteLine("NewStrikeoutAnnotation(): Failed to append strikeout annotation to the document.");
                else
                {
                    Console.WriteLine("NewStrikeoutAnnotation(): annotations '{0}' added to the document '{1}.", helper.config.NEW_SO_ANNOTATION_TEXT, documentName);
                    await helper.DownloadFile(documentName, outputName, "add_strikeout_annotation_");
                }
            }
        }
    }