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

Anchoring Tables

Enthusiast ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Hi All,

I want to select all the tables in a document and it needs to be anchored. Is that possible?

For figures, using grep option "~a" I can achieved my task, how can I proceed for tables. Please help.

Vandy

TOPICS
Scripting

Views

2.7K

Translate

Translate

Report

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

Community Expert , Sep 21, 2012 Sep 21, 2012

@vandy88 – you could look at the "storyOffset" property of all tables. That gives you a different "insertionPoint" object for every Table. Take the Index number of that "insertionPoint", subtract 1 and you have the Index for the Character that represents the table in the story.

Then you could move that character with the "move()" method to an anchored TextFrame, if that is what you want.

Here an example with one text frame that holds one table (and nothing more) in an InDesign file:

var d=app.docum

...

Votes

Translate

Translate
Explorer ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Hi Vandy. What do you want to do with tables? Choosing anchored objects (picture frames) with grep does not allow you to change any object atributes itself (frame fill color, object style, stroke width etc.)  but just those which are typographic - baseline shift, leading, ... . Am I right? I suppose it is the same by tables - even anchored tables are not found by GREP search. So changing typo attributes inside table should GREP do either they are anchored or not and changing the other ones I would do with defining table  styles.

Jura 

Votes

Translate

Translate

Report

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
Enthusiast ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Hi Jura,

Thanks for your valuable reply.

Actually what is my requirement is, I want to search the tables in a document and it needs to be pasted in a anchored text frame.

Is that possible?

Vandy

Votes

Translate

Translate

Report

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
Enthusiast ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Hi,

tables belong to stories and there position is marked by the storyOffset, which is an insertionPoint (1).

So you can add a new textFrame (anchored) there (1) and move the existing table to insertionPoint[0] of this new textFrame.

There will be a lot of circumstances to keep an eye on ... complicated

Hans-Gerd Claßen

Votes

Translate

Translate

Report

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 ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

@vandy88 – you could look at the "storyOffset" property of all tables. That gives you a different "insertionPoint" object for every Table. Take the Index number of that "insertionPoint", subtract 1 and you have the Index for the Character that represents the table in the story.

Then you could move that character with the "move()" method to an anchored TextFrame, if that is what you want.

Here an example with one text frame that holds one table (and nothing more) in an InDesign file:

var d=app.documents[0];

var myTableCharacter = d.stories[0].characters[d.stories[0].tables[0].storyOffset.index-1];

var newTextFrame = d.textFrames.add({geometricBounds:[0,0,100,100]});

myTableCharacter.move(LocationOptions.AFTER,newTextFrame.texts[0].insertionPoints[0]);

Hope, that gives you an idea.

Uwe

Votes

Translate

Translate

Report

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
Enthusiast ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Thanks Hans and Uwe.

Votes

Translate

Translate

Report

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 ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

@vandy88 – in theory you could use the GREP search for the task to identify the special character that represent a Table object in a Texts object.

The special character that represents a Table is "\u0016". But unfortuantely it seems, that it's not supported by the UI or the scripting alternative of Adobe GREP. (Correct me, if I'm wrong. I tested with InDesign CS5.5 7.5.3)

Say, for example, we have one single Table in the document and the text frame that holds the Table is selected, the following code snippet results to "0":

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = "\u0016";

var myTableCharacters = app.selection[0].texts[0].findGrep();

$.writeln(myTableCharacters.length);

//Result: 0

Wheras a regEx (in contrast to the Adobe GREP) can identify a "\u0016" in the contents of a Texts object.

Select the text frame with the Table and run the following code:

var myContents = app.selection[0].texts[0].contents;

var myRegEx = /\u0016/;

myRegEx.test(myContents);
//Result: true

The result is "true". The special character is identified…

Uwe

Votes

Translate

Translate

Report

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 ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

There no need to look for tables like that. This line collects all tables for you:

myTables = app.documents[0].stories.everyItem().tables.everyItem().getElements();

Then you iterate over myTables, using each table's storyOffset to get their insertion point.

Peter

Votes

Translate

Translate

Report

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 ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

@Peter – I know that :-).

It's just interesting to know, that in the case of Tables (and their special characters' representation) a GREP search is not working…

Uwe

Votes

Translate

Translate

Report

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 ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

If a GREP would work, we could easily get really ALL Tables in the document. Also the ones that might be inserted in table cells. Or that ones in states of MultiStateObjects, that are not the active state.

Uwe

Votes

Translate

Translate

Report

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 ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Oops. Forget my last comment about MultiStateObjects. With

app.activeDocument.stories.everyItem();

you relly get all the stories, even those in ALL states of the MultiStateObjects.

Just tested.

Uwe

Votes

Translate

Translate

Report

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 ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

> If a GREP would work

Interestingly, a text search works:

app.findTextPreferences.findWhat = "<0016>"

finds all tables.

Peter

Votes

Translate

Translate

Report

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 ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

@Peter – Ah! That's really a very, very good one!!!
Thanks a lot!

Uwe

Votes

Translate

Translate

Report

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 ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

The interesting thing is, actually, Why Doesn't This Work With GREP?

Internally, the 'placeholder code' for a table is U+0016, so there is no reason for it to Not work with GREP -- unless it has been deliberately suppressed.

Votes

Translate

Translate

Report

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 ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

@Jongware – yeah, might be. But why?

Nonetheless, if you do a Text Search with "<0016>" you easily can get the Table object of its found character representation:

app.findTextPreferences.findWhat = "<0016>";

var tableCharacters = app.documents[0].findText();


//The first Table that the Text Search has found:

$.writeln(tableCharacters[0].texts[0].tables[0]);

Uwe

Votes

Translate

Translate

Report

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 ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

LATEST

@Jongware – the reason WHY that does not work with GREP might be simple: it's just a bug.

Uwe

Votes

Translate

Translate

Report

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