3 Replies Latest reply on Apr 18, 2014 8:49 AM by RickGroff

    Remove Local Formatting AS or JS

    RickGroff Level 1

      I'm working on a script (AS, but I can link to a JS script from it if necessary) that replaces italic, bold, bold italic, small caps, etc., with character styles. Once that's done, I'd like to go through an entire ID file and remove any other local formatting (kerning, extra space above and below, leading changes, etc.).


      I know how to do this from the Find/Replace dialog (search for TX, replace with TX), but can't quite figure out how to script it and have it do the same for all paragraph styles in a job.


      Thanks in advance, gurus!

        • 1. Re: Remove Local Formatting AS or JS
          BEGINNER_X Level 3

          Hi Rick,


          May the below code helpful for you:


          I not able test it here, so please check and get back in case of any issues.


          //First option
          app.activeDocument.stories.everyItem().clearOverrides();    //Clear document including masterpage
          //Second option
          var myStories = app.activeDocument.stories.everyItem().getElements();
          for (i=0; i<myStories.length; i++) {
              if (myStories[i].textContainers[0].parent.parent instanceof MasterSpread || myStories[i].textContainers[0].parent instanceof MasterSpread || myStories[i].textContainers[0].parent.parent.parent instanceof MasterSpread || myStories[i].textContainers[0].parent.parent.parent.parent instanceof MasterSpread) {



          • 2. Re: Remove Local Formatting AS or JS
            Kai Rübsamen Level 4

            Hi Rick,


            try the following:



            var curDoc = app.documents[0];
            var allStories = curDoc.stories.everyItem();
            // clear overrides in stories   
            // clear overrides in footnotes  
            try {   
            catch(e) {}   
            // clear overrides in tables   
            try {   
            catch(e) {}



            • 3. Re: Remove Local Formatting AS or JS
              RickGroff Level 1

              Fabulous, Kai! You make it look so easy. Much appreciated!