15 Replies Latest reply on Sep 21, 2012 8:30 AM by Laubender

    Anchoring Tables

    Sajeev Sridharan Level 4

      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

        • 1. Re: Anchoring Tables
          Kalajda Level 1

          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 

          • 2. Re: Anchoring Tables
            Sajeev Sridharan Level 4

            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

            • 3. Re: Anchoring Tables
              -hans- Level 4

              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

              • 4. Re: Anchoring Tables
                Laubender Adobe Community Professional & MVP

                @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

                • 5. Re: Anchoring Tables
                  Sajeev Sridharan Level 4

                  Thanks Hans and Uwe.

                  • 6. Re: Anchoring Tables
                    Laubender Adobe Community Professional & MVP

                    @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

                    • 7. Re: Anchoring Tables
                      Peter Kahrel Adobe Community Professional & MVP

                      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

                      • 8. Re: Anchoring Tables
                        Laubender Adobe Community Professional & MVP

                        @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

                        • 9. Re: Anchoring Tables
                          Laubender Adobe Community Professional & MVP

                          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

                          • 10. Re: Anchoring Tables
                            Laubender Adobe Community Professional & MVP

                            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

                            • 11. Re: Anchoring Tables
                              Peter Kahrel Adobe Community Professional & MVP

                              > If a GREP would work

                               

                              Interestingly, a text search works:

                               

                              app.findTextPreferences.findWhat = "<0016>"

                               

                              finds all tables.

                               

                              Peter

                              • 12. Re: Anchoring Tables
                                Laubender Adobe Community Professional & MVP

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

                                 

                                Uwe

                                • 13. Re: Anchoring Tables
                                  [Jongware] Most Valuable Participant

                                  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.

                                  • 14. Re: Anchoring Tables
                                    Laubender Adobe Community Professional & MVP

                                    @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

                                    • 15. Re: Anchoring Tables
                                      Laubender Adobe Community Professional & MVP

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

                                       

                                      Uwe