Javascript: ParagraphCollection.getItemAtLocation Method
Description
Gets the Paragraph at a certain geometrical position.
Syntax
<void> ParagraphCollection.getItemAtLocation(<number> x, <number> y, <RequestParagraphCallback> callback, [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| x | Specifies the Paragraph's horizontal location in pixels with an origin at the top left corner. |
| y | Specifies the Paragraph's vertical location in pixels with an origin at the top left corner. |
| callback | Receives the Paragraph at a certain geometrical position. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates ParagraphCollection.getItemAtLocation in a practical document-editing workflow. It gets the Paragraph at a certain geometrical position.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.textParts.getMainText(function(mainText) {
const paragraphs = mainText.paragraphs;
paragraphs.getItemAtLocation(
1,
1,
function(result) {
if (!result) {
console.warn("No paragraph was returned.");
return;
}
console.log("get item at location result:", result);
},
onTxError
);
}, onTxError);