2 Replies Latest reply on Sep 30, 2010 8:02 AM by Marijan Tompa [tomaxxi]

    [JS/CS4] Show a specific page/spread?

    Pontus Uggla Level 1

      How do I show a specific page like I focus a pageItem?


      I guess it has something to do with page.windows[0].select(app.documents.pages[0]);


      Something like that?

        • 1. Re: [JS/CS4] Show a specific page/spread?
          Marijan Tompa [tomaxxi] Level 4



          Dave Saunders wrote great function few years ago for zooming on selected object.

          Original post can be found here:

          Zoom in on Object



          function zoomObject(theObj) {
          try {
            var objBounds = theObj.geometricBounds;
          } catch (e) {
            throw "Object doesn't have bounds."
          var ObjHeight = objBounds[2] - objBounds[0];
          var ObjWidth = objBounds[3] - objBounds[1];
          var myWindow = app.activeWindow;
          var pageBounds = myWindow.activePage.bounds;
          var PgeHeight = pageBounds[2] - pageBounds[0];
          var PgeWidth = pageBounds[3] - pageBounds[1];
          var hRatio = PgeHeight/ObjHeight;
          var wRatio = PgeWidth/ObjWidth;
          var zoomRatio = Math.min(hRatio, wRatio);
          app.select(theObj); // to make active the page that holds theObj
          myWindow.zoomPercentage = myWindow.zoomPercentage * zoomRatio;
          exit() // Because there's no point in doing this if you don't exit to let the user see






          Hope that helps.





          • 2. Re: [JS/CS4] Show a specific page/spread?
            Marijan Tompa [tomaxxi] Level 4



            I think I misunderstood you


            This will go to desired page:


            app.activeWindow.activePage = app.activeDocument.pages[1];


            And you can also fit object to view like this:




            And you have multiple options for page fitting:


            ZoomOptions.ACTUAL_SIZEZooms to 100%.
            ZoomOptions.FIT_PAGECenters the active page in the window.
            ZoomOptions.FIT_SPREADCenters the active spread in the window.
            ZoomOptions.SHOW_PASTEBOARDFits the entire pasteboard in the window.