Skip to content

Tables

The LAY methods that work on the tables are:

getTablesCount

The getTablesCount returns the number of tables in the layout of the document.

For example the instruction:

var tablesCount = LAY.getTablesCount();

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

The syntax is:

LAY.getTablesCount()

getTable

The getTable method returns the block of the table with the given index or undefined if the table index is invalid.

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

var table = LAY.getTable(1);

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

{
    "id": 21,
    "parent": 1,
    "pageNumber": 1,
    "type": "table",
    "x0": 60,
    "y0": 457,
    "x1": 790,
    "y1": 706,
    "children": [22,23,24,25,26,27,28,29,30,31,32,33,34 ... 68,69],
    "beginPos": -1,
    "endPos": -1,
    "tokenBegin": 69,
    "tokenEnd": 177,
    "label": "T1",
    "tableIndex": 1,
    "cellIndex": 12,
    "rows": 7,
    "cols": 6
}

where:

Field name Description Field type Default value
tableIndex The position of the block in the index of the tables Integer -1
cellIndex The position the block of the table's first cell in the index of the cells Integer -1
rows The number of rows of the table Integer -1
cols The number of the columns of the table Integer -1

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

Note

Table indexes are zero-based, in the exampletableIndex= 1 is the index of the second table detected in the layout.

The syntax is:

LAY.getTable(tableIndex)

where tableIndex is the index of the table. It must be contained in the range [0, n], where n is the number of tables in the document.