3 Replies Latest reply on Apr 9, 2015 2:13 PM by lindaeliseruble

    Narrow down search to a specific page?

    lindaeliseruble

      Hello,

       

      How can I narrow down a search to a specific page in a PDF document?

      For instance, I want to search only page 5.

       

       

      How can I do this?

      Is there any documentation that specifically tells you how to narrow down a search to a page number?

       

      Thanks

       

       

      Linda

        • 1. Re: Narrow down search to a specific page?
          George_Johnson MVP & Adobe Community Professional

          What method are you currently using to search? You can use the doc.getPageNthWord to loop through the words on a particular page.

          • 2. Re: Narrow down search to a specific page?
            lindaeliseruble Level 1

            Actually, I need to find a particular page before I do a search on it.

             

            My problem is that I need to search a specific book mark in a large document, however, the particular name of the bookmark appears three times and I want to search all three of these bookmarks.

             

            Currently I am using the following to narrow my search to a specific bookmark:

             

            if (global.mainDoc.bookmarkRoot.children[i].name.indexOf("XYZ")!=-1) {

            // Do something

            }

             

            Unfortunately there are three bookmarks with the same name of XYZ and my search only goes to the last bookmark named XYZ.

            I need to know how I can also search the other two bookmarks named XYZ.

             

            The three same named bookmarks appear one right after the other.  Since I am able to search the last of the same named bookmarks, I would like to then go to the previous page and search that page.  Similarly I would like to go to the previous page before that one and search it as well.

             

            I could obtain the number of the last bookmark named XYZ, subtract one from that page to obtain the previous page, and if there is a way to narrow a search to a page number I could search that page ,with the bookmark named XYZ, as well.

             

            Any help is greatly appreciated.

             

            Thanks

             

             

            Linda

             

             

            • 3. Re: Narrow down search to a specific page?
              lindaeliseruble Level 1

              Actually I have solved my problem.  It was quite easy actually.

               

              I just replaced the green line of code with the red line of code and now all three bookmarks named "Net Charges by Provider" are searched.

               

                if (global.mainDoc.bookmarkRoot.children[i].name.indexOf("Net Charges by Provider")!=-1) {

              //PMPgs = getBookmarkRange(global.mainDoc, global.mainDoc.bookmarkRoot, i);

                PMPgs.push(getBookmarkRange(global.mainDoc, global.mainDoc.bookmarkRoot, i));

                for (var j in PMItms)

                  global.srchVals[PMItms[j]].srchPgs = PMPgs;

                }




              Thanks anyway!

               

               

               

              Linda