Customize annotation interactions in UWP viewer

Customizing Annotation PopupCommandMenu

It is possible to customize the popup annotation menu on the viewer by adding or removing options when creating, selecting and editing annotations.

Example

The sample code below shows how to replace the Delete button for a custom one by listening to OnShowPopupMenu and checking the ShowingPopupMenuEventArgs.

C#

1// Subscrive to OnShowPopupMenu event
2ToolManager.OnShowPopupMenu += ToolManager_OnShowPopupMenu;
3
4// Raised event
5private void ToolManager_OnShowPopupMenu(PopupCommandMenu menu, pdftron.PDF.Tools.ShowingPopupMenuEventArgs eventArgs)
6{
7 // Check if tool type is Editing Annotation
8 if (eventArgs.ToolType == ToolType.e_annot_edit)
9 {
10 // Check if annotation type is Square
11 if (eventArgs.AnnotType == AnnotType.e_Square)
12 {
13 // Find Delete button and remove it
14 menu.MenuItems.Remove(menu.MenuItems.Where(x => x.Tag.ToString() == "delete").FirstOrDefault());
15
16 // Create a custom button with a custom event/action
17 Button button = new Button();
18 button.Content = "Click Me";
19 button.Click += Button_Click;
20
21 /* It accepts a bool parameter that tells if should use * default style or not on the newly added button */
22 menu.AddMenuItem(button, true);
23 }
24 }
25}
26
27private void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
28{
29 // my actions
30}

Default Menu Options

Customized Menu Options

Apryse Docs Image
Apryse Docs Image

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales