Copy link to clipboard
Copied
I have a situation where I have to process some tables in my document. Each page can have more than one table, but there is one table on each page that I need to target. It is the "first" table on the page, in other words, the top-most table on the page. I am using this to get all of the tables on the page:
var tables = page.textFrames.everyItem().tables.everyItem().getElements();
I need to identify the top-most table in this collection. It is not always the first table in the collection, so I can't rely on its position in the collection. Is there a Y location property on a table or one of its objects that I can use to determine the top-most table? Thank you very much.
Rick
You can figure out the y position using the baseline of the storyOffset.
Harbs
Copy link to clipboard
Copied
I think I figured this out. If anyone has a better way, I am open to suggestions. Thanks.
function getPriceTable (tables, doc) {
var table = null;
var currBaseline = 9999;
for (var i = 0; i < tables.length; i += 1) {
if (tables.cells[0].paragraphs[0].baseline < currBaseline) {
table = tables;
currBaseline = tables.cells[0].paragraphs[0].baseline;
}
}
return table;
}
Copy link to clipboard
Copied
You can figure out the y position using the baseline of the storyOffset.
Harbs
Copy link to clipboard
Copied
Hi Harbs,
Thank you very much.
Rick
Find more inspiration, events, and resources on the new Adobe Community
Explore Now