9 Replies Latest reply on Nov 11, 2012 11:56 PM by sundar_r

    make fillcolor to overprint...

    dhishok Level 1

      Hi everyone,

       

      I want to find the texts with fill color "ANNO Cyan" and make this color to Overprint. So i have created the script for find and replace, and it is not completed. Can anyone please help me to complete the script. Find my script below,

       

      //------------------------------------------

       

      app.findTextPreferences = null;
      app.changeTextPreferences = null;

       

      //Set preferences to null
      app.findTextPreferences = NothingEnum.nothing;
      app.changeTextPreferences = NothingEnum.nothing;

       

      //Set find & chang preferences
      app.findTextPreferences.fillColor = "ANNO Cyan";
      app.changeTextPreferences.fillColor.overprintFill = true;

       

      function setupFindText(find, change, foots, hidLayers, lockedLayers, lockedStories, masters, caseSensitive) {
        app.findTextPreferences = null;
        app.changeTextPreferences = null;
        try { app.findTextPreferences.findWhat = find } catch(e) {};
        try {app.changeTextPreferences.changeTo = change } catch(e) {};
        app.findChangeTextOptions.properties = {
          includeFootnotes:(foots == null ? false : foots),
          includeHiddenLayers:(hidLayers == null ? false : hidLayers),
          includeLockedLayersForFind:(lockedLayers == null ? false : lockedLayers),
          includeLockedStoriesForFind:(lockedStories == null ? false : lockedStories),
          includeMasterPages:(masters == null ? false : masters),
          includeCaseSensitive:(caseSensitive == null ? false : caseSensitive)
        }
      } // end setupFindText

       

      alert ("DONE");

      //------------------------------------------

       

      Thanks in advance


      Thiyagu

        • 1. Re: make fillcolor to overprint...
          Dave Saunders Level 4

          First four lines of your script are unnecessary because the function does that.

           

          setupFindText(); // no point having the function if you don't call it.

          //Set find & change preferences
          app.findTextPreferences.fillColor = "ANNO Cyan";
          app.changeTextPreferences.overprintFill = true; // this is changed from your original

          app.documents[0].changeText(); // a change won't happen if you don't call it.

           

          function setupFindText(find, change, foots, hidLayers, lockedLayers, lockedStories, masters, caseSensitive) {
            app.findTextPreferences = null;
            app.changeTextPreferences = null;
            try { app.findTextPreferences.findWhat = find } catch(e) {};
            try {app.changeTextPreferences.changeTo = change } catch(e) {};
            app.findChangeTextOptions.properties = {
              includeFootnotes:(foots == null ? false : foots),
              includeHiddenLayers:(hidLayers == null ? false : hidLayers),
              includeLockedLayersForFind:(lockedLayers == null ? false : lockedLayers),
              includeLockedStoriesForFind:(lockedStories == null ? false : lockedStories),
              includeMasterPages:(masters == null ? false : masters),
              includeCaseSensitive:(caseSensitive == null ? false : caseSensitive)
            }
          } // end setupFindText

           

          alert ("DONE");

          //------------------------------------------

          • 2. Re: make fillcolor to overprint...
            Dave Saunders Level 4

            Uh-oh. Looks like that's an edited version of my setupFindText function. The wholeWord option is gone. That breaks the function. It should be this:

             

            function setupFindText(find, change, wholeWd, caseSense, foots, hidLayers, lockedLayers, lockedStories, masters) {
                app.findTextPreferences = null;
                app.changeTextPreferences = null;
                try { app.findTextPreferences.findWhat = find } catch(e) {};
                try {app.changeTextPreferences.changeTo = change } catch(e) {};
                app.findChangeTextOptions.properties = {
                    caseSensitive:(caseSense == null ? false : caseSense),
                    wholeWord:(wholeWd == null ? false : wholeWd),
                    includeFootnotes:(foots == null ? false : foots),
                    includeHiddenLayers:(hidLayers == null ? false : hidLayers),
                    includeLockedLayersForFind:(lockedLayers == null ? false : lockedLayers),
                    includeLockedStoriesForFind:(lockedStories == null ? false : lockedStories),
                    includeMasterPages:(masters == null ? false : masters)
                }
            } // end setupFindText

             

            Dave

            • 3. Re: make fillcolor to overprint...
              dhishok Level 1

              Hi Dave,

               

              Thanks for your valuable support. While running the script i got an error, please refer the attachments. Then i have came to know that finding the color is giving trouble.

               

              So i have tried character by character search. This script is running without error but nothing can be changed. Can you please look into this and help me. Still i am learner of java scripts. I am learning lot of things from you. Once again thanks dave...

               

              Find my code below:

               

              var myDoc = app.activeDocument;
              var myPage = myDoc.pages.item(0);
              var myTextFrame = myPage.textFrames.add();
              myTextFrame.contents = "";
              var myTextObject = myTextFrame.parentStory.characters.item(0);
              try{
              for(i=1; i>myTextObject; i++){
                  if (myTextObject[i].fillColor = "Teacher ANNO Cyan"){
                      myTextObject[i].fillColorOverprintFill = true;
                      }
                  }
              }
              catch(e){};
              alert ("DONE");

              Thanks in advance


              Thiyagu

              • 4. Re: make fillcolor to overprint...
                dhishok Level 1

                Hi Dave,

                 

                If my previous approach is difficult to change the color to overprint means, can you please suggest any other method to chane fill color of text to overprint. Find the swatches in the styles and changing it to overprint is possible. Our requirement is if the swatches applied to the text manually, and the swatch applied text has to change to overprint. Can you please suggest for this.

                 

                regards

                Thiyagu

                 

                Message was edited by: Thiyaga rajan

                • 5. Re: make fillcolor to overprint...
                  Dave Saunders Level 4

                  The error message and the script don't go together. The string in the error message isn't the same as the string in the script. And the statement causing the error doesn't appear in the script.

                   

                  Dave

                  • 6. Re: make fillcolor to overprint...
                    rajnikids Level 1

                    Hi,

                     

                    I also tried to oveprint the assigned fill colour, but nothing display in overprint options as ticked, as said by Thiyagu. Can you recitify the problem.

                     

                    var myDoc = app.activeDocument;

                    var myPage = myDoc.pages.item(0);

                    var myTextFrame = myPage.textFrames.add();

                    myTextFrame.contents = "";

                    var myTextObject = myTextFrame.parentStory.characters.item(0);

                    try{

                    for(i=1; i>myTextObject; i++){

                        if (myTextObject[i].fillColor = "Infill Magenta"){

                            myTextObject[i].fillColorOverprintFill = true;

                            }

                        }

                    }

                    catch(e){};

                    alert ("DONE");

                    • 7. Re: make fillcolor to overprint...
                      sundar_r Level 1

                      Finally, I found something, please try this out!

                       

                      var mydoc=app.documents.item(0);

                      var myannos=mydoc.stories.everyItem().getElements();

                       

                       

                      for (i=0;i<myannos.length;i++) {

                          var myanno=myannos[i];

                         

                          if (myanno.fillColor.name=="ANNO Cyan") {

                      myanno.overprintFill =true;

                      }

                      }

                       

                      Sundar

                      • 8. Re: make fillcolor to overprint...
                        rajnikids Level 1

                        Hi Sundar,

                         

                        Overprinting happends only to the text selected with fill colour ANNO Cyan.

                         

                        also see this, simple steps,...

                         

                         

                        app.findTextPreferences.fillColor = "Infill Magenta";

                        app.changeTextPreferences.overprintFill = true; // this is changed from your original

                        app.documents[0].changeText(); // a change won't happen if you don't call it.

                         

                        but, i need the overprint applied to rectangles, strokes, etc., filled with ANNO Cyan colour.

                         

                        Could you please help on this.

                        • 9. Re: make fillcolor to overprint...
                          sundar_r Level 1

                          The same I posted to your previous requirement.

                           

                          //Requirement: Overprint fill and stroke all the types and objects for a particular applied swatch

                           

                          var mydoc=app.documents.item(0);

                          var myOPs=mydoc.pageItems;

                          var myannos=mydoc.stories.everyItem().getElements();

                           

                          for (i=0;i<myOPs.length;i++) {

                              var myOP=myOPs[i];

                              //swatch name OP

                          if (myOP.strokeColor.name=="Infill Magenta") {

                              myOP.overprintStroke=true;

                          }

                          else if (myOP.fillColor.name=="Infill Magenta") {

                              myOP.overprintFill=true;

                          }

                          }

                          for (i=0;i<myannos.length;i++) {

                              var myanno=myannos[i];

                           

                          if(myanno.fillColor.name=="Infill Magenta") {

                              myanno.overprintFill=true;

                          }

                          }