6 Replies Latest reply on Dec 4, 2011 11:22 PM by V.Dnath

    INdesign Cs4 java script

    V.Dnath

      hi,,

      Plz,, help me to develope a scripting for

      , i m making  a script in java script for indesign cs4 to the particuler character style on whole document on which it is applying in text and its associated page num with page references

      give me the solution for displaying all  the charcter style with associated page number.

       

      --Indesign Cs4 script to display all the  character style  'KT ' on documents

       

      app.findTextPreferences = null;

      app.findTextPreferences.appliedCharacterStyle = app.activeDocument.characterStyles.item("KT");

      var sourcelist = app.activeDocument.findText();

      //var pages = app.activeDocument.pages;

      myFrame=app.activeDocument.pageItems.item(0);

      myPage=myFrame.parent.name;

      //myPage = app.activeDocument.pages.itemByName(' '+myNumber)

      while (sourcelist.length > 0)

      app.selection[0].parentStory.insertionPoints[-1].contents = sourcelist.pop().contents+myPage+"\r";

       

      --

      but it display only charcter style 'KT' on those text or word where there is applied,, but not give the page number exactly where it is

       

      so plz,, give me solution for this script where java script / apple script

       

       

       

       

      regards

      vijai

        • 1. Re: INdesign Cs4 java script
          Peter Spier Most Valuable Participant (Moderator)

          I have moved your topic to the scripting forum where it will get attention form users with javascript skills.

          • 2. Re: INdesign Cs4 java script
            csm_phil Level 4

            Hi Vijay Singh,

             

            I understand your expectations, You want to get the applied character style KT   page numbers Right?

             

            Please try the below JS codes its use full to your achievements i hope this will help you.

             

             

            var myDoc =app.activeDocument;
            app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
            app.findTextPreferences.appliedCharacterStyle = "KT";
            var mySearch = app.findText(false);
            for(var a=mySearch.length-1; a>=0; a--){
                 var  myText= mySearch[a];
                 var myPagenum = myText.parentTextFrames[0].parent.name;
                 var myContents = myText.contents;
                 app.selection[0].insertionPoints[-1].contents = String(myContents+"\t"+myPagenum);
                 app.selection[0].insertionPoints[-1].contents = "\r";
                 }
            app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
            

             

            thx

            csm_phil

            • 3. Re: INdesign Cs4 java script
              V.Dnath Level 1

              thanks alot sir, yr script fully solved my problem..

              i will tk yr help time to  time

              wih best regards

              vijay singh,

              • 4. Re: INdesign Cs4 java script
                V.Dnath Level 1

                helo.. Sir

                 

                Plz help me once again..

                Actulay i want to change this script into user friendly way, 

                script for search all the charcter style 'KT' with associated page num,

                but now i want to make it as dropdownlist and select the any style and run this script as privious as like given script..

                ---

                var myDoc =app.activeDocument;
                app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
                app.findTextPreferences.appliedCharacterStyle = "KT";
                var mySearch = app.findText(false);
                for(var a=mySearch.length-1; a>=0; a--){
                     var  myText= mySearch[a];
                     var myPagenum = myText.parentTextFrames[0].parent.name;
                     var myContents = myText.contents;
                     app.selection[0].insertionPoints[-1].contents = String(myContents+"\t"+myPagenum);
                     app.selection[0].insertionPoints[-1].contents = "\r";
                     }
                app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

                ---

                plz give me answer as soon as possible...

                thanks

                with warm regards

                vijay singh

                • 5. Re: INdesign Cs4 java script
                  csm_phil Level 4

                  Hi Vijay,

                   

                  Please try the below JS code is GUI based.

                   

                   

                  var myDoc =app.activeDocument;
                  
                  var myLW = 100;
                  var myStyleNames = myDoc.characterStyles.everyItem().name;
                  var myDialog = app.dialogs.add({name:"Character Style KT Page Numbers Create", canCancel:true});
                       with(myDialog.dialogColumns.add()){     
                            with(borderPanels.add()){
                                 with(dialogColumns.add()){staticTexts.add({staticLabel:"Choose the KT Character Style:   ", minWidth:myLW});}
                                      with(dialogColumns.add()){var myChooseStyle = dropdowns.add({stringList:myStyleNames, selectedIndex:0});}
                                      }
                                 }
                  var myResult = myDialog.show();
                  if(myResult == true){
                       var mySelStyle = myStyleNames[myChooseStyle.selectedIndex];
                       myDialog.destroy();
                  }
                  else{
                       myDialog.destroy();
                  }
                  alert(mySelStyle);
                  app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
                  app.findTextPreferences.appliedCharacterStyle = mySelStyle.toString();
                  var mySearch = app.findText(false);
                  for(var a=mySearch.length-1; a>=0; a--){
                       var  myText= mySearch[a];
                       var myPagenum = myText.parentTextFrames[0].parent.name;
                       var myContents = myText.contents;
                       app.selection[0].insertionPoints[-1].contents = String(myContents+"\t"+myPagenum);
                       app.selection[0].insertionPoints[-1].contents = "\r";
                       }
                  app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
                  

                   

                  thx

                  csm_phil

                  • 6. Re: INdesign Cs4 java script
                    V.Dnath Level 1

                    thanks alot sir ... u r so great,,,

                     

                    thanks i hv no words to expreess..my feeling,,