-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
47 lines (37 loc) · 1.56 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using DevExpress.Pdf;
using DevExpress.Xpf.DocumentViewer;
using DevExpress.Xpf.PdfViewer;
using System.Windows;
namespace MarkupAnnotations
{
public partial class MainWindow : DevExpress.Xpf.Core.ThemedWindow
{
public MainWindow()
{
InitializeComponent();
// Load a document.
viewer.OpenDocument("..\\..\\Demo.pdf");
// Handle the TextMarkupAnnotationCreating event to specify the annotation properties.
viewer.AnnotationCreating += Viewer_TextMarkupAnnotationCreating;
}
private void Viewer_TextMarkupAnnotationCreating(DependencyObject d, PdfAnnotationCreatingEventArgs e)
{
if (e.Builder.AnnotationType == PdfAnnotationType.Text || e.Builder.AnnotationType == PdfAnnotationType.TextMarkup)
{
IPdfViewerMarkupAnnotationBuilder annotationBuilder = e.Builder.AsMarkupAnnotationBuilder();
annotationBuilder.Author = "John Smith";
annotationBuilder.Contents = "Note";
annotationBuilder.Color = new PdfRGBColor(0.23, 0.48, 0.34);
}
}
private void viewer_DocumentLoaded(object sender, RoutedEventArgs e)
{
// Select the text to highlight:
viewer.FindText(new TextSearchParameter { Text = "PDF Viewer" });
// Highlight selected text:
viewer.HighlightSelectedText();
//Add a sticky note:
viewer.AddStickyNote(new PdfDocumentPosition(1, new PdfPoint(29, 568)), "Comment");
}
}
}