8 Replies Latest reply on Jan 28, 2017 6:13 AM by Karl Heinz Kremer

    Crop slug areas in Pdf

    tpk1982 Level 4

      Hi All,

       

      I need slug information only for cover page (page 1). Rest of pages need not the slug portions. So am trying to crop the pages to remove slug areas except cover page using crop tool (with trim size).

       

      Is it possible with scripting? I am novice in Acrobat scripting, i tried using with this forum previous thread.

       

      var arrMedia = this.getPageBox({cBox:"Trim", nPage:1});
      arrMedia[0] = 0; 
      arrMedia[1] = 0; 
      arrMedia[2] = 0; 
      arrMedia[3] -= 60; 
      this.setPageBoxes({cBox:"Trim", nStart:1, nEnd:this.numPages-1, rBox:arrMedia});
      

       

      Thanks,

      K

        • 1. Re: Crop slug areas in Pdf
          Karl Heinz Kremer Adobe Community Professional

          Chances are that you want to set the crop box. Do you have a trim box in this document? If not, then also use the crop box in your first line. Also, you don't want to set three of the array members to 0. Please review the API documentation to find out what these values actually mean.

           

          If your slug-line is at the top, you can use this:

           

          var arrMedia = this.getPageBox({cBox:"Crop", nPage:1}); 
          console.println(arrMedia.toSource()); 
          arrMedia[1] -= 60; 
          this.setPageBoxes({cBox:"Crop", nStart:1, nEnd:this.numPages-1, rBox:arrMedia});
          

          If the slug-line is at the bottom, change the one assignment to this:

           

          arrMedia[3] += 60; 
          
          • 2. Re: Crop slug areas in Pdf
            tpk1982 Level 4

            Thanks Karl.

             

            Just want to make sure which measurement it will take by default in script? I have slug in bottom. If i use

             

            arrMedia[3] += 60;

             

            mean the 60 is mm or inches or points?

             

            Also += means it will crop the slug, isnt it? -= means?

             

            Regards,

            K

            • 3. Re: Crop slug areas in Pdf
              try67 MVP & Adobe Community Professional

              The unit is always PostScript Points.

              "+=" means you're adding the value on the right to the existing value, "-=" means you're subtracting from it.

              1 person found this helpful
              • 4. Re: Crop slug areas in Pdf
                tpk1982 Level 4

                But when i use -=, it actually increase the slug portion. I have attached the test file. For example the slug area is 25 pt. Below coding is reduce 25 pt

                 

                var arrMedia = this.getPageBox({cBox:"Crop", nPage:1});   
                arrMedia[3] += 25;   
                this.setPageBoxes({cBox:"Crop", nStart:1, nEnd:this.numPages-1, rBox:arrMedia});
                

                 

                Below coding is increase 25 pt

                 

                var arrMedia = this.getPageBox({cBox:"Crop", nPage:1});   
                arrMedia[3] -= 25;   
                this.setPageBoxes({cBox:"Crop", nStart:1, nEnd:this.numPages-1, rBox:arrMedia});
                

                 

                 

                Dropbox - To test.pdf

                • 5. Re: Crop slug areas in Pdf
                  Karl Heinz Kremer Adobe Community Professional

                  That is correct, that's why - when you compare the two solutions for the top and the bottom  that I provided - you will see that the one for the top uses -= and the one for the bottom uses += to remove the slug line.

                   

                  The reason for this is hidden in the meaning of the four different values you are getting when you retrieve the crop box (or any other page box for that matter). You basically get the coordinates for two points: The upper left corner and the lower right corner. It looks like this:

                   

                  [ ulx, uly, lrx, lry ]
                  

                  This means that when you modify the element with index 3, you are actually modifying the lower right corner y component (which by default is 0). If you add to it, you are moving it up, if you subtract from it, you are moving it down.

                   

                  Again, please read the API documentation. You cannot program in JavaScript for Acrobat without a good understanding of the API.

                  • 6. Re: Crop slug areas in Pdf
                    tpk1982 Level 4

                    Thanks Karl

                    • 7. Re: Crop slug areas in Pdf
                      tpk1982 Level 4

                      Hi Karl,

                       

                      I need to change the value as desired. Is it prompt not works in Acrobat scripting?

                       

                      var myvalue=prompt("enter desired value");
                      var arrMedia = this.getPageBox({cBox:"Crop", nPage:1});   
                      arrMedia[3] += myvalue;   
                      this.setPageBoxes({cBox:"Crop", nStart:1, nEnd:this.numPages-1, rBox:arrMedia});
                      

                       

                      I tried with app.response and it is working, is it the correct method?

                       

                      Regards,

                      K

                      • 8. Re: Crop slug areas in Pdf
                        Karl Heinz Kremer Adobe Community Professional

                        Yes, app.response() is the correct method. You can use response() in a browser, but not in Acrobat. See here for a bit more information: Learning to Program JavaScript for Adobe Acrobat - KHKonsulting LLC