Get Text Annotation by Id from PDF via .NET SDK
API for getting annotations by Id from PDF documents with with Aspose.PDF Cloud .NET SDK.
Get StartedHow to get annotations by Id 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: PM> Install-Package Aspose.Pdf-Cloud
Steps to get annotations by Id 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 annotation by Id from Pdf document.
- Logs details of Annotation.
This sample code shows getting Annotations by Id from PDF document via C#
public async static Task GetTextAnnotation()
{
const string localPdfDocument = @"C:\Samples\sample.pdf";
const string storageFileName = "sample.pdf";
const string annotationId = "GE5TAOZRGAYCYNBVGAWDINJQFQ2TAMA";
// 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]);
}
TextAnnotationResponse response = await pdfApi.GetTextAnnotationAsync(storageFileName, annotationId);
if (response == null)
Console.WriteLine("GetTextAnnotation(): Unexpected error!");
else if (response.Code < 200 || response.Code > 299)
Console.WriteLine("GetTextAnnotation(): Failed to get annotations from the document.");
else
{
Console.WriteLine(JsonConvert.SerializeObject(response.Annotation, Formatting.Indented));
}
}
- Learning Resources
- Documentation
- Source Code
- API References
- Product Support
- Free Support
- Paid Support
- Blog
- Why Aspose.PDF Cloud for .NET?
- Customers List
- Security