Skip navigation
Currently Being Moderated

Anchoring Tables

Sep 21, 2012 3:52 AM

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

 
Replies
  • Currently Being Moderated
    Sep 21, 2012 4:40 AM   in reply to vandy88

    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 

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 5:33 AM   in reply to vandy88

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 5:43 AM   in reply to vandy88

    @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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 6:17 AM   in reply to vandy88

    @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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 6:36 AM   in reply to Laubender

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 6:57 AM   in reply to Peter Kahrel

    @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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 7:00 AM   in reply to Laubender

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 7:05 AM   in reply to Laubender

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 7:26 AM   in reply to Laubender

    > If a GREP would work

     

    Interestingly, a text search works:

     

    app.findTextPreferences.findWhat = "<0016>"

     

    finds all tables.

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 8:04 AM   in reply to Peter Kahrel

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

     

    Uwe

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 8:09 AM   in reply to Laubender

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 8:22 AM   in reply to [Jongware]

    @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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 8:30 AM   in reply to [Jongware]

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

     

    Uwe

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points