var inputFile = Path.Combine(dataDir, "AddAnnotation.pdf");
var outputFile = Path.Combine(dataDir, "AddAnnotation_out.pdf");
var pdfDocument = new Aspose.Pdf.Document(inputFile);
var textAnnotation =
new Aspose.Pdf.Annotations.TextAnnotation(pdfDocument.Pages[1],
new Aspose.Pdf.Rectangle(200, 400, 400, 600))
{
Title = "Sample Annotation Title",
Subject = "Sample Subject"
};
textAnnotation.SetReviewState(Aspose.Pdf.Annotations.AnnotationState.Accepted,"user");
textAnnotation.Contents = "Sample contents for the annotation";
textAnnotation.Open = true;
textAnnotation.Icon = Aspose.Pdf.Annotations.TextIcon.Key;
var border = new Aspose.Pdf.Annotations.Border(textAnnotation)
{
Width = 5,
Dash = new Aspose.Pdf.Annotations.Dash(1, 1)
};
textAnnotation.Border = border;
textAnnotation.Rect =
new Aspose.Pdf.Rectangle(200, 400, 400, 600);
pdfDocument.Pages[1].Annotations.Add(textAnnotation);
pdfDocument.Save(outputFile);