Extends
- Immutable.Record
Members
Methods
Members
The HTML Text
node at the end of this text selection.
Type:
The HTML Text
node offset of at the end of this text selection.
Type:
- number
The page index where the text selection ends.
Type:
- number
The PSPDFKit.TextLine#id of the last text line of this text selection.
Type:
- number
The HTML Text
node at the start of this text selection.
Type:
The HTML Text
node offset of at the start of this text selection.
Type:
- number
The page index where the text selection starts.
Type:
- number
The PSPDFKit.TextLine#id of the first text line of this text selection.
Type:
- number
Methods
Returns the bounding box in client coordinates of the current text selection, or null
if the
selection has been programmatically collapsed.
Returns:
A promise that resolves to the client rect.
- Type
- Promise.<(PSPDFKit.Geometry.Rect|null)>
Example
const textSelection = instance.getTextSelection();
textSelection.getBoundingClientRect().then(rect => console.log(rect));
Returns the individually selected text rectangles in the PDF page space for each page. This can be used to create e.g. PSPDFKit.Annotations.MarkupAnnotations at the current selection.
Returns:
A promise that resolves to a list of rects per page.
- Type
- Promise.<PSPDFKit.Immutable.List.<{pageIndex: number, rects: PSPDFKit.Immutable.List.<PSPDFKit.Geometry.Rect>}>>
Example
const textSelection = instance.getTextSelection();
textSelection.getSelectedRectsPerPage().then(rectsPerPage => {
rectsPerPage.map(({ pageIndex, rects }) => {
// We need to create one annotation per page.
const annotation = new PSPDFKit.Annotations.HighlightAnnotation({
pageIndex,
boundingBox: PSPDFKit.Geometry.Rect.union(rects),
rects,
});
instance.create(annotation);
});
});
Returns an immutable list of all PSPDFKit.TextLines of this text selection.
Returns:
A promise that resolves to a list of all text lines.
- Type
- Promise.<PSPDFKit.Immutable.List.<PSPDFKit.TextLine>>
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
).
Returns:
A promise that resolves to the text.
- Type
- Promise.<string>
Example
const textSelection = instance.getTextSelection();
textSelection.getText().then(text => console.log(text));