2 Replies Latest reply on Dec 22, 2014 6:46 AM by try67

    Bug in setPageBoxes ?

    try67 MVP & Adobe Community Professional

      Can someone test and confirm for me this possible bug I've found in setPageBoxes under Acrobat XI Pro (tested in 11.0.06)?

      I'm basically trying to add some white space to the top of all pages of a document, but am getting very strange results. I'm using this code:

       

      console.println("BEFORE")
      for (var p=0; p<this.numPages; p++) {
          console.println(p+":"+this.getPageBox("Crop", p));
      }
      
      for (var p=0; p<this.numPages; p++) {
          var pageBox = this.getPageBox("Crop", p);
          var newBox = [pageBox[0], pageBox[1], pageBox[2], pageBox[3]];
          newBox[1]+=200;
          this.setPageBoxes({cBox: "Crop", nStart: p, nEnd: p, rBox: newBox});
      }
      
      console.println("\rAFTER")
      for (var p=0; p<this.numPages; p++) {
          console.println(p+":"+this.getPageBox("Crop", p));
      }
      

       

      The result is that only the first and last pages are edited:

       

      BEFORE
      0:0,842,595,0
      1:0,842,595,0
      2:0,842,595,0
      
      AFTER
      0:0,1042,595,0
      1:0,842,595,0
      2:0,1042,595,0
      

       

       

      And if I try it like this (as the page sizes are the same):

       

      console.println("BEFORE")
      for (var p=0; p<this.numPages; p++) {
          console.println(p+":"+this.getPageBox("Crop", p));
      }
      
      var pageBox = this.getPageBox("Crop", 0);
      var newBox = [pageBox[0], pageBox[1], pageBox[2], pageBox[3]];
      newBox[1]+=200;
      this.setPageBoxes({cBox: "Crop", nStart: 0, nEnd: this.numPages-1, rBox: newBox});
      
      console.println("\rAFTER")
      for (var p=0; p<this.numPages; p++) {
          console.println(p+":"+this.getPageBox("Crop", p));
      }
      

       

      The result is that only the first page is edited:

       

      BEFORE
      0:0,842,595,0
      1:0,842,595,0
      2:0,842,595,0
      
      AFTER
      0:0,1042,595,0
      1:0,842,595,0
      2:0,842,595,0
      

       

      Anyone encountered something like this, or can see what I'm doing wrong here?

        • 1. Re: Bug in setPageBoxes ?
          Karl Heinz Kremer Adobe Community Professional

          The behavior of the scripts (that it only processes only the first/last or

          only the first page) certainly seems inconsistent.

           

          When you look at all the page boxes, the media box is always the largest

          (or of the same size as the other boxes), I suspect that you run into a

          problem with trying to extend the crop box past the media box. When I

          change your script and set the media box instead of the crop box in the

          loop, I do get the expected results. This is for a document that only has a

          media box defined.

           

          When you retrieve the crop box from a page that does not have a crop box

          defined, you get the media box automatically. I suspect that things will

          get a bit more complex if your document has both a valid media box and crop

          box defined for each page. In this case, you would have to adjust the media

          box to have enough space for the larger crop box.

          • 2. Re: Bug in setPageBoxes ?
            try67 MVP & Adobe Community Professional

            Thanks for looking into it, Karl. I think you're correct because I've now tried the same code (both versions), first on the Media box and then on the Crop box and it seems to work correctly. It's just strange that the results of running it on just the Crop box are so inconsistent.

            Anyway, your solution seems to work, so thanks!