1 Reply Latest reply on Apr 2, 2016 8:34 AM by try67

    search/query function passes back page number, automatically set bookmarks

    ralf85

      Dear all,

       

      I have got three questions concerning the implementation of a java script.

       

      1) Is there a function in JavaScript that passes back the page numbers where the search tag has been matched in the document? The result should be an array that can be used in a for-loop, not a search result by the Acorbat application.

       

      2) Is there a function that automatically (without an input by the user) generates bookmarks on certain pages (using a for-loop through the array, question no. 1)?

       

      3) Is there a function that deletes certain pages (identified by the array) after the bookmarks being generated?

       

      Thank you for your help.

       

      Best regards

       

      Ralf

        • 1. Re: search/query function passes back page number, automatically set bookmarks
          try67 MVP & Adobe Community Professional

          You can do all of it, but you'll need to write the code for it, of course. You can't use the search object for it, though, as it doesn't return any values.

          The way to so it is to use the getPageNthWord method in combination with the getPageNumWords method. Using these two methods you can write a loop that iterates over all the pages in the file, and then another loop that iterates over all the words in each page. Doing so will allow you to know on which page(s) a match was found on your search term and you could then do what you want with that information (export it, delete the pages, etc.).

          However, it is important to keep in mind that this method is much slower than the built-in query command and might cause the application to stall or even freeze entirely if used on a large file with a lot of words in it, so it's important to write your code as efficiently as possible when performing this kind of task.