HTML JPG PDF XML DOCX
  Product Family
PDF

Travailler avec les annotations dans PDF via .NET SDK

API pour gérer les annotations dans les documents PDF avec .NET.

Get Started

Comment travailler avec les annotations dans les documents PDF en utilisant Cloud .NET SDK

Pour travailler avec les annotations dans les documents PDF via Cloud .NET SDK, nous utiliserons Aspose.PDF Cloud .NET SDK Ce SDK Cloud vous permet de créer facilement des applications de création, d’édition et de conversion de PDF basées sur le cloud en C#, ASP.NET, ou d’autres langages .NET pour diverses plateformes cloud. Ouvrez NuGet gestionnaire de paquets, recherchez Aspose.PDF Cloud et installez. Vous pouvez également utiliser la commande suivante depuis la console du gestionnaire de paquets.

Commande de la console du gestionnaire de paquets


    PM> Install-Package Aspose.Pdf-Cloud
     

Étapes pour ajouter des annotations en utilisant .NET SDK

Les développeurs Aspose.PDF Cloud peuvent facilement charger et ajouter des annotations aux documents PDF en quelques lignes de code.

  1. Téléchargez le PDF.
  2. Créez une zone de texte stylisée (avec polices, couleurs, alignement).
  3. Soumettez l’annotation à la page spécifiée.
  4. Télécharge le document modifié pour une utilisation locale.
 

Cet exemple de code montre l'ajout d'annotations au document 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_");
                }
            }
        }
    }