8 Replies Latest reply on Dec 19, 2017 5:46 AM by aliw1

    Unable to get loop to work for crop

    aliw1 Level 1

      Hi,

       

      I am trying to change the crop box by a 10th of its height and length on every page of a PDF.

       

      So if the 1st page is 100 by 100 it would be come 110 by 110. If the second page is 200 by 200 it would become 220 by 220 leaving new white space to the top and right which I intend to add a watermark.

       

      This seems to work fine, but for some reason its only working on the active page, and not looping thorough each page.

       

      I am no Java expert so I am probably missing something very simple, here is my code:

       

      for (var i = 0; i <= this.numPages; i++)

      {

       

          var rectCrop = this.getPageBox("Crop",i);

          var width = rectCrop[2];

          var height = rectCrop[1];

       

          var new_width = width+width / 10;

          var new_height = height+height / 10;

          

          var rectNewCrop = [ 0, new_height, new_width, 0 ];

       

          this.setPageBoxes("Crop", i, i, rectNewCrop);

      }

       

      It is hurting my brain trying to figure this out so any advice would be greatly appreciated.

       

      Cheers,

      Alistair