10 Replies Latest reply on Mar 10, 2015 6:10 AM by vladan saveljic

    Find tables stroke in registration color and change in K

    vladan saveljic Level 4

      Hi,

      I received one indd file with many tables which have strokes in registration color.

      Is there a way to find automatically the tables with registration color and change them with 100% k?

      Thank you in advance

      oscar

       

        • 1. Re: Find tables stroke in registration color and change in K
          SJRiegel Adobe Community Professional & MVP

          You can find them using preflight. Define a profile that disallows Registration as a color, and you can find all the instances. You will have to manually change them.

          Screen Shot 2015-03-09 at 10.24.19 AM.pngScreen Shot 2015-03-09 at 10.24.55 AM.png

          • 2. Re: Find tables stroke in registration color and change in K
            Willi Adelberger Most Valuable Participant

            Hopefully your file was done with table and cell style (why shouldn't anyone work without styes?), correct the styles.

            • 3. Re: Find tables stroke in registration color and change in K
              rob day Adobe Community Professional & MVP
              Is there a way to find automatically the tables with registration color and change them with 100% k?

               

              It can be scripted. If you are using OSX this Applescript should work:

               

              tell application "Adobe InDesign CC 2014"

                  set k to item 1 of (every swatch of active document whose name is "Black")

                  set r to item 1 of (every swatch of active document whose name is "Registration")

                  set c to every cell of every table of every text frame of active document

                  repeat with x in c

                      if the top edge stroke color of x is r then

                          set top edge stroke color of x to k

                      end if

                      if the right edge stroke color of x is r then

                          set right edge stroke color of x to k

                      end if

                      if the bottom edge stroke color of x is r then

                          set bottom edge stroke color of x to k

                      end if

                      if the left edge stroke color of x is r then

                          set left edge stroke color of x to k

                      end if

                  end repeat

              end tell

               


              • 4. Re: Find tables stroke in registration color and change in K
                Laubender Adobe Community Professional & MVP

                @Oscar – first I would do a visual preflight with Separation Preview and the total amount of colors set to 400%.

                That will give you an individual view on all elements with 400% amount of color or more. Might be sufficient to identify all elements filled and stroked in registration color. Here an example of a table where parts of the cell strokes are formatted with Registration Color:

                 

                RegistrationColorInTables.png

                 

                Then I would run a script like the one from Rob (AppleScript for Mac OSX version of InDesign) on the document.

                 

                First I would test with one single table copied to a new document.

                If that will work fine, I'd use it on a duplicate of your original one.

                 

                And then I would do a visual test with Separation Preview again.

                 

                @Rob – Also we could hope, that there are no nested tables (tables inside tables, tables in anchored text frames or grouped text frames*, tables in footnotes). To get tables in anchored text frames, or tables in grouped text frames, simply address all tables in all stories of the document.

                Tables in footnotes would be a different case. Also tables nested in table cells.

                 

                Here is an ExtendScript version of your AppleScript one a little bit extended.

                It will run on all tables of all stories of the active document.

                One can undo the whole action with one single Undo command.

                 

                What is not covered are the possibility of different gap colors for the strokes.
                Also see possible problems with the stroke order defined in the table. See below.

                 

                //ChangeCellStrokeColors.jsx
                //Uwe Laubender
                
                //DESCRIPTION:Will *also* work in German version of InDesign
                
                /**
                * @@@BUILDINFO@@@ ChangeCellStrokeColors.jsx !Version! Mon Mar 09 2015 18:55:52 GMT+0100
                */
                
                app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
                
                app.doScript(
                    doIt,
                    ScriptLanguage.JAVASCRIPT,
                    [],
                    UndoModes.ENTIRE_SCRIPT,
                    "Change color of strokes of tables"
                    );
                
                
                function doIt(){
                
                var findStrokeColorByName = "Registration";
                var changeStrokeColorByName = "Black";
                
                var findColor = app.documents[0].colors.itemByName(findStrokeColorByName);
                var changeColor = app.documents[0].colors.itemByName(changeStrokeColorByName);
                
                //*Not cells* in tables of footnotes or nested tables in tables.
                //But also tables inside of anchored text frames, nested objects like pasted inside text frames with tables and grouped text frames:
                var allCells = app.documents[0].stories.everyItem().tables.everyItem().cells.everyItem().getElements();
                
                for(var n=0;n<allCells.length;n++){
                   
                    // try/catch: Maybe not necessary, but in case a gap color is defined, it wouldn't hurt:
                    try{
                    if(allCells[n].topEdgeStrokeColor === findColor){allCells[n].topEdgeStrokeColor = changeColor};
                    }catch(e){};
                   
                    try{
                    if(allCells[n].rightEdgeStrokeColor === findColor){allCells[n].rightEdgeStrokeColor = changeColor};
                    }catch(e){};
                   
                    try{
                    if(allCells[n].leftEdgeStrokeColor === findColor){allCells[n].leftEdgeStrokeColor = changeColor};
                    }catch(e){};
                   
                    try{
                    if(allCells[n].bottomEdgeStrokeColor === findColor){allCells[n].bottomEdgeStrokeColor = changeColor};
                    }catch(e){};
                   
                   
                    };
                
                };
                

                 

                What can go wrong with that script or doing recoloring of the cell's strokes in the UI?
                Order of strokes in adjacent cells could be different from order of cells visited by the script.

                 

                There is a table property for this:
                strokeOrder

                 

                There are four possible values for strokeOrder:

                StrokeOrderTypes.ROW_ON_TOP

                StrokeOrderTypes.COLUMN_ON_TOP

                StrokeOrderTypes.BEST_JOINS

                StrokeOrderTypes.INDESIGN_2_COMPATIBILITY

                 

                I will not go into detail here ;-)
                This post is long enough.

                 

                Uwe

                • 5. Re: Find tables stroke in registration color and change in K
                  vladan saveljic Level 4

                  Thanks to all.

                  @SRiegel - Yes I can find all the instances in this ant in other ways but I would like to avoid changing them manually.

                   

                  @Willi Adelberger - in my office, we all work with styles but this file I received from other company and unfortunately the file contain many many defects.

                   

                  @rob day – I have Mac os X yosemite and indesign cs6. Your script unfortunately gives me a error line 1

                   

                  @Laubender - Your script is excellent. In a moment changes evry registration color in K.

                  Thank you very much

                  • 6. Re: Find tables stroke in registration color and change in K
                    Laubender Adobe Community Professional & MVP

                    @Oscar – ok, my script is working with your document.


                    Please check the visible results in context with other stroke colors adjacent to the now black ones.

                    See my warning on the property of strokeOrder of the table itself.

                     

                    Uwe

                    • 7. Re: Find tables stroke in registration color and change in K
                      Laubender Adobe Community Professional & MVP

                      @Oscar – can you specify the exact error message you will get with Rob's script?
                      Maybe addressing the application with "Adobe InDesign CC 2014" is not specific enough, since we have three versions of InDesign CC 2014 out?

                       

                      v10.0.0

                      v10.1.0

                      v10.2.0

                       

                      Or should the name be: "Adobe InDesign CC 2014.app" when addressing InDesign by AppleScript on Mac OSX 10.10 (Yosemite) ?

                       

                      //EDIT:
                      Or the whole path to the app is needed?

                       

                      Uwe

                      • 8. Re: Find tables stroke in registration color and change in K
                        vladan saveljic Level 4

                        I checked the visible results and stroke order. It's all good (all tables had strocke order: row on top and for me it is ok also after change)

                        About error code:

                        error code.png

                        Thanks a lot

                        • 9. Re: Find tables stroke in registration color and change in K
                          rob day Adobe Community Professional & MVP

                          About error code:

                           

                          Uwe's right my AppleScript wouldn't deal with complex layouts that have tables buried in groups, other tables, etc. and it sounds like his javascript is working for you.

                           

                          I think the reason you are getting an error with my AppleScript is, it needs to be compiled in Apple's Script Editor (not ExtendScript) and saved with a .scpt extention. Script Editor is normally found in Applications>Utilities