2 Replies Latest reply on Jun 5, 2008 3:35 AM by (jethroso)

    JavaScript: Is there a way to move text from de clipboard to a js variable ?

      Now I use an alternative that is (roughly):

      1. Save the actual insertionPoint (where I want to put the final result)
      2. Create (or use a predefined) textframe off of the page.
      3. Select that textFrame and paste the clipboard contents
      4. Reselect the original insertionPoint and then begin a loop for each
      paragraph:
      5. Apply several procces to the paragraph (this include tokenize the
      input, format and replace of common errors).
      6. Insert the data back to de insertionPoint with apropiate
      paragraphStyles.

      I did'nt place the clipboard text directly into the final textframe because there are content before and after the insertionPoint and not all of the paste text is actually used. I fill better doing the text processing in a separated place and later insert it.

      This method work very well, except for the visual jump to the textFrame and back to the insertionPoint, and the change in the page view position.

      I will be happy if I can place the clipboart text directly into a javascript variable and avoid the creation of an auxilizary textframe.

      Thanks.
        • 1. Re: JavaScript: Is there a way to move text from de clipboard to a js variable ?
          I assume you are copying some text from somewhere, perhaps another file.
          If this file is text file you can also read the contents of the file into a variable as a string.
          Process this string and set it as contents of your text frame.

          I hope this helps you.

          Grtn, Kees
          • 2. Re: JavaScript: Is there a way to move text from de clipboard to a js variable ?
            Level 1
            > If this file is text file you can also read the contents of the file
            > into a variable as a string.
            > Process this string and set it as contents of your text frame.

            Yes, I can do that way (I'm considering anyway), but I have a lot of textframes linked across several pages (more than 80 pages in fact) and I have to put the inserted text in diferent places of this multipage linked textframe. And the information a have to put in the document isn't in sequent but scattered along the pages.

            For me is easiest to copy from original file (spreedsheet document) a bunch of selected rows, place the insertionPoint it in the correct place in the document and run the script for generate the data. Next select another rows and repeat the process in other place.

            The other way I'm thinking of is to copy all rows I need (actualy not all rows of the documnt) ignoring the order in which I want it, import into indesign and later copy and paste in correct place.

            Maybe I have to rethink the whole process, but for now it works.

            Thanks anyway