2 Replies Latest reply on Jul 19, 2011 2:07 PM by JoseAjáAjá

    findText(): not in whole document but in selected pages.

    JoseAjáAjá Level 1

      Hi all:

       

      I'm writing an extension for searching some text in specific pages. (in ActionScript, from Flash Builder 4- Usign the CS_SDK 1.5, for InDesign CS5.5). [See note at the end of the document]

       

      FIND IN THE WHOLE DOCUMENT: EASY

       

      So far, the code is working perfectly for finding within the WHOLE DOCUMENT.

       

      I understand this is so, because I'm using the "findText()" method of the "Document" class, like so:

       

       

      case wholeDocRB:
           foundText     = inDesignDocument.findText() as Array;
           break;
      

       

      It works great.

       

      FIND IN JUST A RANGE: I JUST CAN'T!

       

      But, if I want to find only in a range of pages, I don't know how to access an available findText() method for ONLY THE PAGES RANGE.

       

      I've tried:

       

       

       

      case pagesRangeRB:
           var fromPage     :Page     = inDesignDocument.pages.item( (ini_TI.text as Number) - 1);
           var toPage          :Page     = inDesignDocument.pages.item( (fin_TI.text as Number) - 1);
           var pagesRange     :*     = inDesignDocument.pages.itemByRange(fromPage,toPage); 
           
           foundText = pagesRange.findText() as Array;
           break;
      

       

       

      ...and...:

       

       

       

      case pagesRangeRB:
           var fromPage     :Page     = inDesignDocument.pages.item( (ini_TI.text as Number) - 1);
           var toPage          :Page     = inDesignDocument.pages.item( (fin_TI.text as Number) - 1);
           var pagesRange     :*     = inDesignDocument.pages.itemByRange(fromPage,toPage); 
           var framesRange     :*     = pagesRange.textFrames.everyItem();
      
           foundText = framesRange.findText() as Array;
           break;
      

       

       

       

       

      I know I'm not strong-typing my variables, but if I do so, then the compiler won't let me run some methods (like "findText()" for instance).

       

      It seems I can't get it to work.

       

       

      WHAT THE GUIDE SAYS: IT CAN BE DONE

      Doesn't say how, however.

       

      The "InDesignCS4_ScriptingGuide_JS.pdf" explictly says:

       

       

       

      [page 91]

       

      While the following script fragment searches the entire document, you also can search stories, text frames, paragraphs, text columns,

      or any other text object. The findText method and its parameters are the same for all text objects.

       

       

       

      But I just can't find the way to reference the text elements in these pages for using the "findText()" method.

       

       

      So, the question again would be:

       

      How to use findText() not in whole document but in selected pages. Or is it there a workaround that could be used?

       

      Thank you guys. Help is much appreciated.

       

       

      _____________

       

      Note: I put this question here and not in the Creative Suite SDK forum, because it relates more to the DOM of InDesign and how to deal with it, instead of to SDK specific problems. Tell me if you think whether it shouldn't be posted here.

        • 1. Re: findText(): not in whole document but in selected pages.
          [Jongware] Most Valuable Participant

          JoseAjáAjá wrote:

           

          WHAT THE GUIDE SAYS: IT CAN BE DONE

          Doesn't say how, however.

           

          The "InDesignCS4_ScriptingGuide_JS.pdf" explictly says:

           

           

           

          [page 91]

           

          While the following script fragment searches the entire document, you also can search stories, text frames, paragraphs, text columns,

          or any other text object. The findText method and its parameters are the same for all text objects.

           

           

           

          But I just can't find the way to reference the text elements in these pages for using the "findText()" method.

           

          All of the mentioned DOM objects derive from Text. "Page", however, does NOT.

           

          A single page can hold several text frames and/or several different stories. And you also cannot search through a selection of stories either.

          However, since you can search through a textframe, perhaps you can make it work on a selection of text frames (I don't think so, as it seems to contradict what I know so far, but you can always try).

          1 person found this helpful
          • 2. Re: findText(): not in whole document but in selected pages.
            JoseAjáAjá Level 1

            Thx for answering, Jongware. Sorry for not coming to you before.

             

            Look, it took me a while to solve this issue. It had some stuff related to the CS-SDK itself, as well as with the InDesign DOM, so I posted another question in the Creative Suite SDK forum.

             

            For those interested, my approach to solving it (thanks to Jongware and Ten A for the help) is in this post:

             

            http://forums.adobe.com/message/3808416#3808416

             

            Thanks to all.

             

             

            *PS. Any comments are welcome.