HTML
JPG
PDF
XML
DOCX
PDF
Add FreeText Annotations to PDF via .NET SDK
API for adding annotations to PDF documents with .NET.
Get StartedHow to append annotations to PDF documents using Cloud .NET SDK
In order to add annotations to PDF documents via Cloud .NET SDK , 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 add annotations using .NET SDK
Aspose.PDF Cloud developers can easily load & append annotations to PDF documents in just a few lines of code.
- Uploads the PDF.
- Creates a styled text box (with fonts, colors, alignment).
- Submits the annotation to the specified page.
- Downloads the modified document for local use.
This sample code shows adding annotations to PDF document
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_");
}
}
}
}