Skip to main content
Inspiring
January 22, 2013
Answered

Duplicating Tables

  • January 22, 2013
  • 1 reply
  • 793 views

There's a lot of things that I like about the way that tables are setup. Among them the idea I can assign contents to a table and have them fill to the correct cell as long as the data is formatted correctly.

However two things irk me about tables:

     1) They have no geometric bounds.

     2) You can't use the duplicate method on them.

Why are tables setup like this? It seems to me that tables are interfaced with in a way that no other objects are.

Thanks for your thoughts.

This topic has been closed for replies.
Correct answer Peter Kahrel

1. Tables live in paragraphs, even constitute paragraphs, and since paragraphs have no geometric bounds, tables therefore have no geometric bounds either. But you can still get some information (a table's storyOffset returns an insertionPoint):

// Right-hand side of the table:

myTable.storyOffset.paragraphs[0].endHorizontalOffset

// Bottom of the table:

t.storyOffset.baseline

// Left-hand side of the table:

myTable.storyOffset.horizontalOffset

The top of the table is either the top of the text frame (if the table is in the first paragraph of a text frame) or can be derived from the baseline of the preceding paragraph.

2. Since tables live in their own paragraphs, and paragraphs can be duplicated, duplicating the table's parent paragraph therefore duplicates the table. To duplicate a table at the end of the story it occurs in, use this:

myTable.storyOffset.paragraphs[0].duplicate (LocationOptions.after, myTable.storyOffset.parentStory.insertionPoints[0]);

Peter

1 reply

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
January 22, 2013

1. Tables live in paragraphs, even constitute paragraphs, and since paragraphs have no geometric bounds, tables therefore have no geometric bounds either. But you can still get some information (a table's storyOffset returns an insertionPoint):

// Right-hand side of the table:

myTable.storyOffset.paragraphs[0].endHorizontalOffset

// Bottom of the table:

t.storyOffset.baseline

// Left-hand side of the table:

myTable.storyOffset.horizontalOffset

The top of the table is either the top of the text frame (if the table is in the first paragraph of a text frame) or can be derived from the baseline of the preceding paragraph.

2. Since tables live in their own paragraphs, and paragraphs can be duplicated, duplicating the table's parent paragraph therefore duplicates the table. To duplicate a table at the end of the story it occurs in, use this:

myTable.storyOffset.paragraphs[0].duplicate (LocationOptions.after, myTable.storyOffset.parentStory.insertionPoints[0]);

Peter

KuddRowwAuthor
Inspiring
January 22, 2013

Peter this was very helpful.

Thank-you!