HTML
JPG
PDF
XML
DOCX
PDF
Get Page Annotations from PDF via .NET SDK
API for getting annotations from PDF documents with with Aspose.PDF Cloud .NET SDK.
Get StartedHow 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.
- Uploads a document.
- Retrieves all annotations from a specified page.
- Logs details of each.
- 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#
public async static Task GetPageAnnotations()
{
const string localPdfDocument = @"C:\Samples\sample.pdf";
const string storageFileName = "sample.pdf";
const int pageNumber = 1;
// Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required).
var pdfApi = new PdfApi(AppSecret, AppSid);
var filesOnStorage = await pdfApi.GetFilesListAsync("");
if (filesOnStorage.Value.All(f => f.Name != storageFileName))
{
using var file = File.OpenRead(localPdfDocument);
var uploadResult = await pdfApi.UploadFileAsync(storageFileName, file);
Console.WriteLine(uploadResult.Uploaded[0]);
}
AnnotationsInfoResponse response = await pdfApi.GetPageAnnotationsAsync(storageFileName, pageNumber);
if (response == null)
Console.WriteLine("GetAnnotations(): Unexpected error!");
else if (response.Code < 200 || response.Code > 299)
Console.WriteLine("GetAnnotations(): Failed to get annotations from the document.");
else
Console.WriteLine(JsonConvert.SerializeObject(response.Annotations, Formatting.Indented));
}