Skip to content

Words

The LAY methods that work on the words are:

LAY.getWordsCount()

Returns the number of words detected in the document.

For example the instruction:

var wordCount = LAY.getWordsCount();
returns the integer value 95 in the wordCount variable.

LAY.getWord(wordIndex)

Returns the word object with the given index, or undefined if the index is invalid.

For example the instruction:

var word = LAY.getWord(40);

returns the following object in the word variable:

{
    "index": 40,
    "start": 235,
    "end": 242,
    "blockId": 19,
    "fontId": 1,
    "x0": 554,
    "y0": 376,
    "x1": 627,
    "y1": 391
}
Field name Description Field type Default value
index Word index Integer -1
start Word starting point Integer -1
end Word ending point Integer -1
fontId The font ID. In the example in Fonts items, fontId=1 means FranklinGothic Demi Integer -1

Watch the Blocks fields to know about the common fields of this object.

LAY.getWordText(wordIndex)

Returns the text contained in the word object with the given index, or undefined if the index is not valid.

For example the instruction:

var wordText = LAY.getWordText(3);

returns the string value INVOICE in the variable wordText.