2 Replies Latest reply on May 12, 2011 7:52 AM by try67

    odd and even rotating pages by file name

    dale_print

      Hi all,

       

      Hoping someone can help me trouble shoot my script below.

       

      The aim is to determined if the last two digits of the file name are odd or even and then rotate the file accordingly.

       

      I have been able to get the page rotation work by it's self but it seems to do nothing at all when trying to get the last two digits of the filename and use them as the variable "pgNum".

       

      Files will be named using the following convention....

      aa-02-02.pdf

       

      Thank you in advance for you help.

       

      =======================================================================================

       

      var re = /.*\/|\.pdf$/ig;
      var filename = this.path.replace(re,"");;

      var pgNum = filename.substring(-2);

       

      try {
          if(pgNum % 2) {
              var crtpagerotate = this.getPageRotation({nPage:i});
              this.setPageRotations({nStart: i, nEnd: i, nRotate:(270+crtpagerotate)%360});
              }
          else {
              var crtpagerotate = this.getPageRotation({nPage:i});
              this.setPageRotations({nStart: i, nEnd: i, nRotate:(90+crtpagerotate)%360});
              }
          }
      catch (e)
          {
          console.println("Batch Aborted: " + e )
          }