1 Reply Latest reply on Nov 16, 2011 8:20 AM by Loic.Aigon

    [JS CS5.5] cycle through and display pages

    RobertGazzillo

      I want to be able to cycle through and display the pages in a document.

      Pretty simple, just can't figure out how to actually display the page.

       

      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

      if(app.documents.length != 0){

              if (app.activeDocument.pages.length !=0){

                  myPages = app.activeDocument.pages

                  for(myCounter = 0; myCounter < myPages.length; myCounter ++){

                      myPage = myPages[myCounter];

                      now how do I display the page and fit to screen ?

                      $.sleep(1000)

                     

                  }

              }

       

      Thank You.

        • 1. Re: [JS CS5.5] cycle through and display pages
          Loic.Aigon Adobe Community Professional

          doc.layoutWindows[0].activePage = doc.pages[0];

           

           

          as for the zoom I use this function from Harbs or Kasyan or Peter (I can't remeber )

           

          //Zoom to the object

          function zoomObject(theObj) {

                    var theObjLength = 0;

           

                    if(theObj.hasOwnProperty ("baseline")){

                              theObj = theObj.characters[0].getElements()[0].parentTextFrames[0];

                    }

                     objBounds = theObj.geometricBounds;

                     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);

                     myWindow.zoom(ZoomOptions.fitPage);

                     myWindow.zoomPercentage = myWindow.zoomPercentage*2;// * zoomRatio;

          }

           

          Best,

           

          Loic

          http://www.loicaigon.com