3 Replies Latest reply on Jun 28, 2017 1:56 AM by SimonLinden

    Understanding the itemByRange function

    SimonLinden Level 1

      I have a script that loops over each page in the document and does a number of things. In some of my documents I have a few pages I want to ignore at the beginning so for those docs I want a new Pages object pointing to a limited number of pages, starting from the first page where my mainTextFrame starts and then every page until the end of the document. Pages.itemByRange() would seem ideal for this, but I'm running into  problems.


      var bookPages = myDoc.pages;
      var newPageRange = bookPages.itemByRange(mainTextFrames[0].parentPage, bookPages[bookPages.length-1]);


      I thought this would work but apparently the function returns a Page object (though the API says it returns Pages). The returned object seems to contain all information from all Pages in the range but I don't know how to extract it in a coherent way. For instance newPageRange.index returns an array of all indexes of these pages. I want to be able to loop over these pages like I can with the original myDoc.pages array.


      I also tried:

        newBookPages = newPageRange.properties;

      But even though this gives me an array to loop over it is not an array of pages which is what I need for the script I've written.

      Is it just me or is the documentation really unclear about this? Any suggestions?