HTML JPG PDF XML DOCX
  Product Family
PDF

Agregar anotaciones de texto resaltado a PDF a través de .NET SDK

API para agregar anotaciones a documentos PDF con .NET.

Get Started

Cómo agregar anotaciones a documentos PDF usando Cloud .NET SDK

Para agregar anotaciones a documentos PDF a través de Cloud .NET SDK, utilizaremos Aspose.PDF Cloud .NET SDK Este SDK en la nube le permite crear fácilmente aplicaciones de creación, edición y conversión de PDF basadas en la nube en C#, ASP.NET u otros lenguajes .NET para diversas plataformas en la nube. Abra NuGet el administrador de paquetes, busque Aspose.PDF Cloud e instale. También puede usar el siguiente comando desde la Consola del Administrador de Paquetes.

Comando de la Consola del Administrador de Paquetes


    PM> Install-Package Aspose.Pdf-Cloud
     

Pasos para agregar anotaciones usando .NET SDK

Los desarrolladores de Aspose.PDF Cloud pueden cargar y agregar fácilmente anotaciones a documentos PDF en solo unas pocas líneas de código.

  1. Sube el PDF al almacenamiento en la nube.
  2. Crea una nueva anotación de resaltado con posición, color, texto y estilo definidos.
  3. Envía la anotación a la página especificada utilizando la API de Aspose Cloud.
  4. Verifica la respuesta y registra el resultado.
  5. Descarga el archivo actualizado para uso local.
 

Este código de muestra muestra cómo agregar anotaciones a un documento PDF


    using Aspose.Pdf.Cloud.Sdk.Model;

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

                List<HighlightAnnotation> annotations = new List<HighlightAnnotation>
                {
                    new HighlightAnnotation(
                        Name: "Highlight_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_HL_ANNOTATION_TEXT,
                        Subject: helper.config.NEW_HL_ANNOTATION_SUBJECT,
                        Contents: helper.config.NEW_HL_ANNOTATION_CONTENTS,
                        Title: helper.config.NEW_HL_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.PostPageHighlightAnnotationsAsync(documentName, pageNumber, annotations, folder: remoteFolder);

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