Select PDF annotations using JavaScript
Nutrient Web SDK enables you to select annotations using the built-in user interface (UI) or programmatically.
Set the
enableClipboardActions
property totrue
to use keyboard shortcuts. For more information, refer to the API reference guide.
Using the built-in UI
There are multiple methods for selecting annotations directly through the UI.
To select a single annotation, left-click the desired annotation within the viewport.
To select multiple annotations, use one of the following methods:
-
Click the Select Multiple Annotations toolbar item, left-click, and draw a rectangle with your mouse around all the annotations you want to select.

-
Select a single annotation by clicking it and then press Shift to select more annotations one by one.
-
Press Control (Windows) or Command (macOS), left-click, and draw a rectangle with your mouse around all those annotations that you want to select.
-
Press Control-A (Windows) or Command-A (macOS) to select all annotations on the page.
Grouping annotations
Grouping multiple annotations enables you to select the same set of annotations in the future and perform actions on all of them in one go. After grouping annotations, select the whole group by clicking only one of the annotations in the group.
Group the selected annotations in one of the following ways:
-
Click the Group toolbar item.

-
Press Control-G (Windows) or Command-G (macOS).
Ungroup the annotations in one of the following ways:
-
Click the Ungroup toolbar item.

-
Click one of the annotations in the group, and press Control-Shift-G (Windows) or Command-Shift-G (macOS).
Modifying multiple annotations
After selecting multiple annotations, perform one of the following actions:
-
Drag all the selected annotations to a new location on the page.
-
Copy all the selected annotations by pressing Control-C (Windows) or Command-C (macOS).
-
Paste all the selected annotations by pressing Control-V (Windows) or Command-V (macOS).
-
Duplicate all the selected annotations by pressing Control-D (Windows) or Command-D (macOS).
-
Delete all the selected annotations by pressing Del (Windows) or Command-Backspace (macOS).
Programmatically
To select annotations, pass the annotation IDs to the setSelectedAnnotations
method:
instance.setSelectedAnnotations(
PSPDFKit.Immutable.List(["annotationsOrAnnotationsIds"])
);
To deselect the currently selected annotations, pass null
to the setSelectedAnnotations
method.