The NutrientViewer.TextLine#id of the last text line of this text selection.
The HTML Text node at the end of this text selection.
The HTML Text node offset of at the end of this text selection.
The page index where the text selection ends.
The NutrientViewer.TextLine#id of the last text line of this text selection.
Returns the bounding box in client coordinates of the current text selection, or null if the
selection has been programmatically collapsed.
A promise that resolves to the client rect.
Returns the individually selected text rectangles in the PDF page space for each page. This can be used to create e.g. NutrientViewer.Annotations.MarkupAnnotations at the current selection.
A promise that resolves to a list of rects per page.
const textSelection = instance.getTextSelection();
textSelection.getSelectedRectsPerPage().then(rectsPerPage => {
rectsPerPage.map(({ pageIndex, rects }) => {
// We need to create one annotation per page.
const annotation = new NutrientViewer.Annotations.HighlightAnnotation({
pageIndex,
boundingBox: NutrientViewer.Geometry.Rect.union(rects),
rects,
});
instance.create(annotation);
});
});
Returns an immutable list of all NutrientViewer.TextLines of this text selection.
A promise that resolves to a list of all text lines.
Returns the text of this text selection. Text blocks will be joined by a new line character
(\n).
The NutrientViewer.TextLine#id of the first text line of this text selection.
The HTML Text node at the start of this text selection.
The HTML Text node offset of at the start of this text selection.
The page index where the text selection starts.
The NutrientViewer.TextLine#id of the first text line of this text selection.
Returns a new instance of this Record type with all values set to their default values.
Returns a new instance of this Record type with the value for the specific key set to its default value.
Returns the value associated with the provided key, which may be the default value defined when creating the Record factory function.
If the requested key is not defined by this Record type, then notSetValue will be returned if provided. Note that this scenario would produce an error when using Flow or TypeScript.
OptionalnotSetValue: anyDeeply converts this Record to equivalent native JavaScript Object.
Note: This method may not be overridden. Objects with custom serialization to plain JS may override toJSON() instead.
Shallowly converts this Record to equivalent native JavaScript Object.
Shallowly converts this Record to equivalent JavaScript Object.
Information about the currently selected text in the PDF. You can listen for changes using the NutrientViewer.EventName.TEXT_SELECTION_CHANGE.
Example
Read the currently selected text of an Instance
Register a TextSelectionChangeEvent
instance.addEventListener("textSelection.change", (textSelection) => { if (textSelection) { console.log("text is selected"); } else { console.log("no text is selected"); } });