4 Replies Latest reply on Jun 17, 2015 1:24 PM by Daniel Sterchi

    Apply Function Only to Specific Frame

    The Gothamite Level 1

      Hello everyone!

       

      I have a project in which I duplicate a text frame using the following command

       

      function copypaste() {

      var doc = app.activeDocument;

      var page = doc.pages[0];

      var frame1 = page.textFrames[0];

      var frame2 = page.textFrames[1];

      frame2.texts.everyItem().select();

      app.copy();

      frame1.texts.everyItem().select();

      app.paste();

      }

       

      which leads me to having two text frames with identical content. However, I want one text frame to be formatted from a raw, text form and the other one needs certain words extracted. Think of it like "One is text, the other one is tags for archival purposes", because - to be honest - that's pretty much what it is.

       

      I have all the word-extraction and all the formatting down, because that wasn't so hard. The only thing that I'm completely stumped on is how to direct functions at a certain text frame.

       

      An example: Let's say I want to have the function "applyRedParagraph" only applied to text frame 1 and "extractBlueWords" only applied to text frame 2.

       

      How do I do that?

       

      Thanks for your help!

        • 1. Re: Apply Function Only to Specific Frame
          Daniel Sterchi Adobe Community Professional

          Hi Gothamite

           

          Is there a rule which text frames should be what?

           

          One possibility is that you select text frames, then call a JavaScript, select the next few text frames and so on.

           

          kind regards

           

          Daniel (from Switzerland)

          • 2. Re: Apply Function Only to Specific Frame
            Vamitul Level 4

            don't use copy paste. DO NOT!

            try something like:

            var doc = app.activeDocument;

            var page = doc.pages[0];

            var frame1 = page.textFrames[0];

            var frame2=frame1.duplicate(page);

            applyRedParagraph(frame1);

            extractBlueWords(frame2);

            • 3. Re: Apply Function Only to Specific Frame
              The Gothamite Level 1

              Daniel Sterchi wrote:

               

              Hi Gothamite

               

              Is there a rule which text frames should be what?

               

              One possibility is that you select text frames, then call a JavaScript, select the next few text frames and so on.

               

              kind regards

               

              Daniel (from Switzerland)

              Hi Daniel

               

              No, there's no difference. Let's say I have frame_1 and frame_2. And action_1 and action_2.

               

              It doesn't matter if action_1 is applied to frame_1 or frame_2 as long as the the frame action_1 does not apply to has action_2 applied.

              • 4. Re: Apply Function Only to Specific Frame
                Daniel Sterchi Adobe Community Professional

                if I get that right you choose text frames manually and apply an action_1. All the text frames on which you didn't apply action_1, action_2 has to be applied. Is that correct?

                If this is correct one can solve the problem with two little (it depends on what you want to do) JavaScrips. You could select text frames then run JavaScript_1. If all the frames that action_1 should be applied are done, then you can run a second JavaScript that tackles the other action.

                 

                kind regards

                 

                Daniel (from Switzerland)