Skip to content

Words

The LAY methods that work on the words are:

getWordsCount

The getWordsCount returns the number of words detected in the document.

For example the instruction:

var wordCount = LAY.getWordsCount();
sets a variable called wordCount that, considering the Extract example output described in the dedicated page, is set to the value of 95.

The syntax is:

LAY.getWordsCount()

getWord

The getWord method returns the word object with the given index, or undefined if the index is invalid.

For example, considering the Extract example output introduced in the dedicated page, the instruction:

var word = LAY.getWord(40);

sets a word variable whose value is an object corresponding to the specified word index:

{
    "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.

The syntax is:

LAY.getWord(wordIndex)

where wordIndex is the index of the word.

getWordText

The getWordText method 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);

sets a variable called wordText that, considering the Extract example output described in the dedicated page, is set to the value of INVOICE.

The syntax is:

LAY.getWordText(wordIndex)

where wordIndex is the index of the word.