HTML JPG PDF XML DOCX
  Product Family
PDF

Get Page Annotations from PDF via .NET SDK

API for getting annotations from PDF documents with with Aspose.PDF Cloud .NET SDK.

Get Started

How to get page annotations from PDF documents using Cloud .NET SDK

For getting page annotations from PDF documents, we’ll use Aspose.PDF Cloud .NET SDK This Cloud SDK allows you to easily build cloud-based PDF creator, editor & converter apps in C#, ASP.NET, or other .NET languages for various cloud platforms. Open NuGet package manager, search for Aspose.PDF Cloud and install. You may also use the following command from the Package Manager Console.

Package Manager Console Command


    PM> Install-Package Aspose.Pdf-Cloud
     

Steps to get annotations using .NET SDK

Aspose.PDF Cloud developers can easily load & get annotations from PDF documents in just a few lines of code.

  1. Uploads a document.
  2. Retrieves all annotations from a specified page.
  3. Logs details of each.
  4. Returns the ID of the first Text annotation (for further actions like editing or deletion).
 

This sample code shows getting Page Annotations from PDF document via C#


    using Aspose.Pdf.Cloud.Sdk.Model;

    namespace Annotations
    {
        public class GetAnnotations
        {
            public static async Task<string> RequestAnnotationsOnPageAsync(AnnotationsHelper helper, string documentName, int pageNumber, string remoteFolder)
            {
                // Get annotations from the page in the PDF document.
                await helper.UploadFile(documentName);

                string annotationResult = string.Empty;
                AnnotationsInfoResponse response = await helper.pdfApi.GetPageAnnotationsAsync(documentName, pageNumber, folder: remoteFolder);

                if (response == null)
                    Console.WriteLine("RequestAnnotationsOnPageAsync(): Unexpected error!");
                else if (response.Code < 200 || response.Code > 299)
                    Console.WriteLine("RequestAnnotationsOnPageAsync(): Failed to request annotations from the document.");
                else
                {
                    foreach (AnnotationInfo annotation in response.Annotations.List)
                    {
                        Console.WriteLine("RequestAnnotationsOnPageAsync(): annotation '{0}' with '{1}' contents get from the '{2}' page of the document '{3}.", [annotation.Id, annotation.Contents, pageNumber, documentName]);
                        if (string.IsNullOrEmpty(annotationResult) &&
                            annotation.AnnotationType == AnnotationType.Text)
                        {
                            annotationResult = annotation.Id;
                        }
                    }
                }
                return annotationResult;
            }
        }
}