@codeforcoffee
We have implemented the feature in Aspose.PDF Cloud API to add annotations to PDF documents. Now, Aspose.PDF Cloud API supports several Annotation types, some of them are Strikeout Annotations, Highlight Annotations, Line Annotations, Circle Annotations, Polyline Annotations, Square Annotations, Squiggly Annotations, Text Annotations and Redaction Annotations.
Please check the following C# example to add comments to PDF document using free text Annotation. You may check the documentation for more details.
Working with Annotation in Aspose.PDF Cloud
Steps to Add Comments to PDF in C#
- Create a new Project in Visual Studio and install Aspose.PDF Cloud NuGet package
- Add Aspose.PDF Cloud API reference to the project
- Initialize the Aspose.PDF Cloud API
- Upload input document to Cloud storage
- Initialize the FreeTextAnnotation object and set the required properties
- Add comments to PDF page using PostPageFreeTextAnnotations request
- Download and Save the output PDF document to your local drive
Code to Add Comments to PDF in C#
using Aspose.Pdf.Cloud.Sdk.Api;
using Aspose.Pdf.Cloud.Sdk.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestConsoleApp
{
class Program
{
static void Main(string[] args)
{
String fileName = "02_pages.pdf";
String remoteFolder = "Temp";
// Initialzie Aspose.PDF Cloud API
// Get Cilent ID and Client Secret from https://dashboard.aspose.cloud/
PdfApi pdfApi = new PdfApi(MyAppKey, MyAppSid);
// Upload source PDF file to aspose cloud storage
pdfApi.UploadFile(remoteFolder + "/" + fileName, System.IO.File.OpenRead("C:/Temp/02_pages.pdf"));
// Add Free Text Annotation to uploaded PDF file
List<FreeTextAnnotation> annotations = new List<FreeTextAnnotation>
{
new FreeTextAnnotation(Rect: new Aspose.Pdf.Cloud.Sdk.Model.Rectangle(100, 600, 200, 700),
TextStyle: new TextStyle(FontSize: 12, Font: "Arial", ForegroundColor: new Aspose.Pdf.Cloud.Sdk.Model.Color(0xFF, 0, 0xFF, 0), BackgroundColor: new Aspose.Pdf.Cloud.Sdk.Model.Color(0xFF, 0xFF, 0, 0)))
{
Name = "Test Free Text",
Flags = new List<AnnotationFlags> { AnnotationFlags.Default},
HorizontalAlignment = HorizontalAlignment.Center,
Intent = FreeTextIntent.FreeTextTypeWriter,
RichText = "Aspose.PDF Cloud API",
Subject = "Text Box Subj",
ZIndex = 1,
Justification = Justification.Center,
Title = "Title"
}
};
var response = pdfApi.PostPageFreeTextAnnotations(fileName, 1, annotations, folder: remoteFolder);
// Download file Cloud storage
var downloadResponse = pdfApi.DownloadFile(remoteFolder + "/" + fileName);
var fileStream = System.IO.File.Create("C:/Temp/FreeTextAnnotation.pdf");
downloadResponse.CopyTo(fileStream);
fileStream.Close();
Console.WriteLine("Completed");
Console.ReadKey();
}
}
}