HTML JPG PDF XML DOCX
  Product Family
PDF

Làm việc với Chú thích trong PDF qua .NET SDK

API để quản lý chú thích trong tài liệu PDF với .NET.

Get Started

Các hành động phổ biến nhất với Chú thích trong .NET

Cách làm việc với chú thích trong tài liệu PDF sử dụng Cloud .NET SDK

Để làm việc với chú thích trong tài liệu PDF qua Cloud .NET SDK, chúng ta sẽ sử dụng Aspose.PDF Cloud .NET SDK SDK Đám mây này cho phép bạn dễ dàng xây dựng các ứng dụng tạo, chỉnh sửa & chuyển đổi PDF dựa trên đám mây trong C#, ASP.NET hoặc các ngôn ngữ .NET khác cho các nền tảng đám mây khác nhau. Mở NuGet trình quản lý gói, tìm kiếm Aspose.PDF Cloud và cài đặt. Bạn cũng có thể sử dụng lệnh sau từ Bảng điều khiển Trình quản lý Gói.

Lệnh Bảng điều khiển Trình quản lý Gói


    PM> Install-Package Aspose.Pdf-Cloud
     

Các bước thêm chú thích sử dụng .NET SDK

Các nhà phát triển Aspose.PDF Cloud có thể dễ dàng tải & thêm chú thích vào tài liệu PDF chỉ trong vài dòng mã.

  1. Tải lên PDF.
  2. Tạo một hộp văn bản có kiểu dáng (với phông chữ, màu sắc, căn chỉnh).
  3. Gửi chú thích đến trang được chỉ định.
  4. Tải xuống tài liệu đã chỉnh sửa để sử dụng cục bộ.
 

Mã mẫu này cho thấy cách thêm chú thích vào tài liệu 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_");
                }
            }
        }
    }