Tables
The LAY
methods that work on the tables are:
LAY.getTablesCount()
Returns the number of tables in the layout of the document.
For example the instruction:
var tablesCount = LAY.getTablesCount();
returns the integer value 2 in the tablesCount
variable.
LAY.getTable(tableIndex)
Returns the block of the table with the given index or undefined
if the table index is invalid.
Info
The index of the table is not the id of the block. It must be contained in the range [0, n]
, where n
is the number of tables in the document.
For example the instruction:
var table = LAY.getTable(1);
returns the following object in the table
variable:
{
"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 tables'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.