6 Replies Latest reply on Sep 4, 2012 12:22 PM by EranSchoellhorn

    This shouldn't be that hard... (Cropping)

    EranSchoellhorn

      So I'm new to the craft but I'm hoping I can get this fairly simple task automated.

      I've basically got three portions of each page that I want to crop down and export into individual files.

       

      function cropPage(p,box,top,bottom)

      {

                var rect = this.getPageBox(box);

                var newRect = new Array();

                newRect[0] = rect[0];

                newRect[1] = rect[1] + (top);

                newRect[2] = rect[2];

                newRect[3] = rect[3] + (bottom);

                this.setPageBoxes(box,p,p,newRect);

      }

       

      this.pageNum = 0;

      var nPages = this.numPages;

       

      for (p=0; p <= nPages; p)

      {

                cropPage(p,"Crop",0,276);

                p = p + 1 ;

                cropPage(p,"Crop",-138,138);

                p = p + 1 ;

                cropPage(p,"Crop",-276,0);

                p = p + 1 ;

      }

       

       

      My script currently triplicates each page in order and then would ideally crop each page in a different location.

       

      While the triplication works just fine, my cropping loop seems to act unpredicatably. Affecting my crop indivudually works fine but when run in the loop everything seems to fall apart. Even if I try and just perform a single crop in the loop, it seems to crop the first page differently than the rest...

       

      for (p=0; p <= nPages; p++)

      {

                cropPage(p,"Crop",0,276);

      }

       

      I've tried just about everything I can come up with considering my limited knowledge and I wouldn't be surprised if it's something simple...

      I'd be eternally grateful for some help on this...

       

      Thanks!