// For complete examples and data files, please go to https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-.NET
// Create instance of annotator.
AnnotationConfig cfg = CommonUtilities.GetConfiguration();
AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler();
if (!Directory.Exists(cfg.StoragePath))
{
Directory.CreateDirectory(cfg.StoragePath);
}
// Create document data object in storage.
var document = documentRepository.GetDocument("Document.pdf");
long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf");
// Create annotation object
AnnotationInfo textFieldAnnotation = new AnnotationInfo
{
AnnotationPosition = new Point(852.0, 201.0),
FieldText = "text in the box",
FontFamily = "Arial",
FontSize = 10,
Box = new Rectangle(66f, 201f, 64f, 37f),
PageNumber = 0,
Type = AnnotationType.TextField,
CreatorName = "Anonym",
DocumentGuid = documentId
};
//Add annotation to storage
CreateAnnotationResult createTextFieldAnnotationResult = annotator.CreateAnnotation(textFieldAnnotation);
// Set background color of annotation
SaveAnnotationTextResult setBackgroundColorResult = annotator.SetAnnotationBackgroundColor(createTextFieldAnnotationResult.Id, 16711680);