5 Replies Latest reply on Dec 18, 2008 9:00 AM by dougneale

    [CS4][JS] Accessing skewed text items

    dougneale Level 1
      The following code snippet successfully finds all the skewed text in a
      document and then removes the skew:

      //Clear the find/change preferences.
      app.findTextPreferences = NothingEnum.nothing;
      app.changeTextPreferences = NothingEnum.nothing;
      //Set the find options.
      app.findChangeTextOptions.caseSensitive = false;
      app.findChangeTextOptions.includeFootnotes = false;
      app.findChangeTextOptions.includeHiddenLayers = false;
      app.findChangeTextOptions.includeLockedLayersForFind = false;
      app.findChangeTextOptions.includeLockedStoriesForFind = false;
      app.findChangeTextOptions.includeMasterPages = false;
      app.findChangeTextOptions.wholeWord = false;
      //Search the document for all the skewed text
      app.findTextPreferences.skew = 1;
      // now remove all skews
      app.changeTextPreferences.skew = 0;

      However, I want to access each fragment of skewed text rather than
      globally change them.

      How do I access the collection of skewed text items as the
      findTextPreferences does not seem to possess the required properties.

      TIA

      Doug Neale
        • 1. Re: [CS4][JS] Accessing skewed text items
          Peter Kahrel Adobe Community Professional & MVP
          You say something like this:
          >var myFound = app.activeDocument.findText();

          which creates an array (myFound) of of all found items. You can process that array as usual, i.e.
          >for (i = 0; i < myFound.length; i++)

          > // do something with each myFound[i]

          Peter
          • 2. Re: [CS4][JS] Accessing skewed text items
            dougneale Level 1
            Hi Peter,

            I tried this on a single page document with some text set in italics:

            //Clear the find/change preferences.
            app.findTextPreferences = NothingEnum.nothing;
            app.changeTextPreferences = NothingEnum.nothing;
            //Set the find options.
            app.findChangeTextOptions.caseSensitive = false;
            app.findChangeTextOptions.includeFootnotes = false;
            app.findChangeTextOptions.includeHiddenLayers = false;
            app.findChangeTextOptions.includeLockedLayersForFind = false;
            app.findChangeTextOptions.includeLockedStoriesForFind = false;
            app.findChangeTextOptions.includeMasterPages = false;
            app.findChangeTextOptions.wholeWord = false;
            //Search the document for all the skewed text
            app.findTextPreferences.skew = 1;

            var myFound = app.activeDocument.findText();


            if (myFound.length==0) {
            alert("No skewed text was found");
            }
            else {
            // ok we have some skewed text, now loop through each one
            for (i =0; i < myFound.length; i++) {
            var myTextObject = myFound[i];
            var myText = myTextObject.Content;
            }
            }

            and it always finishes up with the alert :-(
            and debug confirmed that myFound.length was zero.

            Should I be doing something else to find italic text?

            Regards,

            Doug Neale
            • 3. Re: [CS4][JS] Accessing skewed text items
              Peter Kahrel Adobe Community Professional & MVP
              Well, you're searching text skewed by 1 degree, so you're not going to find italics. If that's what you're after, do app.findTextPreferences.fonStyle = 'Italic' instead.

              Peter
              • 4. Re: [CS4][JS] Accessing skewed text items
                Level 1
                Italic and Skew are two different things. The skew value for text is an explicit number representing to angle of skew, so finding all skewed text is going to be a tad difficult. You might have to do it by exception, that is, look for a skew of zero and any text you don't find is skewed.

                Dave
                • 5. Re: [CS4][JS] Accessing skewed text items
                  dougneale Level 1
                  Thanks Guys,

                  That did the trick.

                  If the skewed text is initially in italics, it is picked up by looking
                  for all italic text.

                  If not, then I shall have to work through all the story textStyleRanges
                  one by one., and if there are tables present, every cell as well.

                  Regards,

                  Doug Neale