HTML JPG PDF XML DOCX
  Product Family
PDF

Trabajar con Anotaciones en PDF a través de .NET SDK

API para gestionar anotaciones en documentos PDF con .NET.

Get Started

Cómo trabajar con anotaciones en documentos PDF usando Cloud .NET SDK

Para trabajar con anotaciones en documentos PDF a través de Cloud .NET SDK, utilizaremos Aspose.PDF Cloud .NET SDK Este Cloud SDK te permite crear fácilmente aplicaciones en la nube para crear, editar y convertir PDFs en C#, ASP.NET u otros lenguajes .NET para varias plataformas en la nube. Abre NuGet el gestor de paquetes, busca Aspose.PDF Cloud e instala. También puedes usar el siguiente comando desde la Consola del Gestor de Paquetes.

Comando de la Consola del Gestor de Paquetes


    PM> Install-Package Aspose.Pdf-Cloud
     

Pasos para agregar anotaciones usando .NET SDK

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

  1. Sube el PDF.
  2. Crea un cuadro de texto con estilo (con fuentes, colores, alineación).
  3. Envía la anotación a la página especificada.
  4. Descarga el documento modificado para uso local.
 

Este código de ejemplo muestra cómo agregar anotaciones al documento 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_");
                }
            }
        }
    }