Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Y Location of a Table

Community Expert ,
Jan 13, 2012 Jan 13, 2012

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

TOPICS
Scripting
834
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 14, 2012 Jan 14, 2012

You can figure out the y position using the baseline of the storyOffset.

Harbs

Translate
Community Expert ,
Jan 13, 2012 Jan 13, 2012

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;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 14, 2012 Jan 14, 2012

You can figure out the y position using the baseline of the storyOffset.

Harbs

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 17, 2012 Jan 17, 2012
LATEST

Hi Harbs,

Thank you very much.

Rick

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines