HTML JPG PDF XML DOCX
  Product Family
PDF

通过.NET SDK处理PDF中的注释

用于管理PDF文档中注释的API,适用于.NET。

Get Started

在.NET中最受欢迎的注释操作

如何使用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. 创建一个带有字体、颜色、对齐的样式化文本框。
  3. 提交注释到指定页面。
  4. 下载已修改的文档以供本地使用。
 

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


    using Aspose.Pdf.Cloud.Sdk.Model;

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

                List<FreeTextAnnotation> annotations = new List<FreeTextAnnotation>
                {
                    new FreeTextAnnotation(
                        Name: "Freetext_NEW_Annotation",
                        Rect: new Rectangle(100,350, 450,400),
                        Flags: new List<AnnotationFlags>() { AnnotationFlags.Default },
                        HorizontalAlignment: HorizontalAlignment.Left,
                        Intent: FreeTextIntent.FreeTextTypeWriter,
                        Justification: Justification.Center,
                        RichText: helper.config.NEW_FT_ANNOTATION_TEXT,
                        Subject: helper.config.NEW_FT_ANNOTATION_SUBJECT,
                        Contents: helper.config.NEW_FT_ANNOTATION_CONTENTS,
                        Title: helper.config.NEW_FT_ANNOTATION_DESCRIPTION,
                        ZIndex: 1,
                        TextStyle: new TextStyle(
                            FontSize:        20,
                            Font: "Arial",
                            ForegroundColor: new Color( A: 0xFF, R: 0x00, G: 0xFF, B: 0x00),
                            BackgroundColor: new Color( A: 0xFF, R: 0xFF, G: 0x00, B: 0x00)
                        ),
                        Modified: "03/27/2025 00:00:00.000 AM"
                    )
                };
                AsposeResponse response = await helper.pdfApi.PostPageFreeTextAnnotationsAsync(documentName, pageNumber, annotations, folder: remoteFolder);

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