Hierarchy
Properties
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.
Example
const textSelection = instance.getTextSelection();
textSelection.getBoundingClientRect().then(rect => console.log(rect));
() => Promise<NutrientViewer.Immutable.List<{ … }>>
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.
Example
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.
Example
const textSelection = instance.getTextSelection();
textSelection.getSelectedTextLines().then(lines => console.log(lines));
Returns the text of this text selection. Text blocks will be joined by a new line character
(\n).
Example
const textSelection = instance.getTextSelection();
textSelection.getText().then(text => console.log(text));
The NutrientViewer.TextLine#id of the first text line of this text selection.
Immutable Record API
31
"[iterator]"(): IterableIterator<
[
keyof { … },
| string
| number
| Text
| (() => Promise<string>)
| (() => Promise<NutrientViewer.Immutable.List<NutrientViewer.TextLine>>)
| (() => Promise<NutrientViewer.Geometry.Rect | null>)
| (() => Promise<NutrientViewer.Immutable.List<{ … }>>)
| null,
],
>Returns
IterableIterator<
[
keyof { … },
| string
| number
| Text
| (() => Promise<string>)
| (() => Promise<NutrientViewer.Immutable.List<NutrientViewer.TextLine>>)
| (() => Promise<NutrientViewer.Geometry.Rect | null>)
| (() => Promise<NutrientViewer.Immutable.List<{ … }>>)
| null
]
>
Returns
thisSee Also
Map#asImmutable
Returns
thisSee Also
Map#asMutable
Returns a new instance of this Record type with all values set to their default values.
Returns
this
delete<K extends keyof { … }>(key: K): this
Returns a new instance of this Record type with the value for the specific key set to its default value.
Parameters
otherunknownReturns
boolean
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.
- has(
key: string,
): key is
| "startTextLineId"
| "startNestedContentBlockId"
| "startPageIndex"
| "startNode"
| "startOffset"
| "endNestedContentBlockId"
| "endTextLineId"
| "endPageIndex"
| "endNode"
| "endOffset"
| "getText"
| "getSelectedTextLines"
| "getBoundingClientRect"
| "getSelectedRectsPerPage"Parameters
keystringReturns
key is
| "startTextLineId"
| "startNestedContentBlockId"
| "startPageIndex"
| "startNode"
| "startOffset"
| "endNestedContentBlockId"
| "endTextLineId"
| "endPageIndex"
| "endNode"
| "endOffset"
| "getText"
| "getSelectedTextLines"
| "getBoundingClientRect"
| "getSelectedRectsPerPage"
Returns
number
Parameters
keyPathIterable<unknown>...collectionsunknown[]Returns
this
Parameters
keyPathIterable<unknown>...collectionsunknown[]Returns
this
remove<K extends keyof { … }>(key: K): this
Parameters
keyPathIterable<unknown>valueunknownReturns
this
Deeply 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.
Returns
{ … }
Shallowly converts this Record to equivalent native JavaScript Object.
Returns
{ … }
Shallowly converts this Record to equivalent JavaScript Object.
Returns
{ … }
toSeq(): Keyed<
keyof { … },
| string
| number
| Text
| (() => Promise<string>)
| (() => Promise<NutrientViewer.Immutable.List<NutrientViewer.TextLine>>)
| (() => Promise<NutrientViewer.Geometry.Rect | null>)
| (() => Promise<NutrientViewer.Immutable.List<{ … }>>)
| null,
>Returns
Keyed<
keyof { … },
| string
| number
| Text
| (() => Promise<string>)
| (() => Promise<NutrientViewer.Immutable.List<NutrientViewer.TextLine>>)
| (() => Promise<NutrientViewer.Geometry.Rect | null>)
| (() => Promise<NutrientViewer.Immutable.List<{ … }>>)
| null
>
Parameters
keyPathIterable<unknown>updater(value: unknown) => unknownReturns
this
Returns
booleanSee Also
Map#wasAltered
Note: Not all methods can be used on a mutable collection or within
withMutations! Onlysetmay be used mutatively.Parameters
mutator(mutable: this) => unknownReturns
thisSee Also
Map#withMutations
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 "textSelection.change" event listener
instance.addEventListener("textSelection.change", (textSelection) => { if (textSelection) { console.log("text is selected"); } else { console.log("no text is selected"); } });