private void AddAnnotation(object sender, RoutedEventArgs e) { // add annotation based on button's tag value. Button button = (Button)sender; string actionName = button.Tag as string; if (this.document != null && this.document.NativePage != null && this.document.Page != null) { if (actionName == "star") { Annotation starAnnotation = new RubberStampAnnotation(new Boundary(10, 400, 50, 440), AnnotationFlags.Default); FixedContent fixedContent = new FixedContent("ap01", new Boundary(0, 0, 40, 40)); fixedContent.Content.AppendImage("star", 0, 0, 40, 40); starAnnotation.Appearance.Normal = fixedContent; this.document.NativePage.Annotations.Add(starAnnotation); this.document.PageViewModel.Annotations.Add(new StarAnnotationViewModel(starAnnotation, this.document.Page)); } else if (actionName == "smile") { Annotation starAnnotation = new RubberStampAnnotation(new Boundary(60, 400, 100, 440), AnnotationFlags.Default); FixedContent fixedContent = new FixedContent("ap01", new Boundary(0, 0, 40, 40)); fixedContent.Content.AppendImage("smile", 0, 0, 40, 40); starAnnotation.Appearance.Normal = fixedContent; this.document.NativePage.Annotations.Add(starAnnotation); this.document.PageViewModel.Annotations.Add(new SmileAnnotationViewModel(starAnnotation, this.document.Page)); } else if (actionName == "text") { FreeTextAnnotation textAnnotation = new FreeTextAnnotation(new Boundary(60, 400, 260, 500)); string sampleText = "sample text"; textAnnotation.Appearance.Normal = AnnotationsHelper.CreateNormalAppearance(sampleText, 200, 100); // set properties affecting default appearance to be used as fallback textAnnotation.FontSize = 12; textAnnotation.BorderEffect = new AnnotationBorderEffect(AnnotationBorderEffectStyle.NoEffect, 0); textAnnotation.Contents = sampleText; // text and border color textAnnotation.TextColor = RgbColors.White.Components; // set background here if needed textAnnotation.Color = RgbColors.Green.Components; this.document.NativePage.Annotations.Add(textAnnotation); this.document.PageViewModel.Annotations.Add(new TextAnnotationViewModel(textAnnotation, this.document.Page)); } } }