1 Reply Latest reply on Mar 27, 2013 10:31 AM by Kasyan Servetsky

    Reducing page height

    Dan Byer Level 1

      All I need to do is cut the bottom off of every page in my documents without changing the layout at all. I'm staring blankly at the scripting dictionary and it's become apparent (again) I just don't speak Applescript. I've been playing with both reframe and resize and I just can't grasp what these things are doing, where I went wrong, and what I need to change to make it do what I need it to do.

       

      This is the kind of thing I'm trying, but the output is NOTHING like I would expect.

       

      tell every page

      resize in inner coordinates from top left anchor by replacing current dimensions with values {8, 8}

      end tell

       

      The 'in inner coordinates" has me particularly flummoxed. What the heck does that even mean? I've tried other options like pasteboard coordinates, parent coordinates, etc. but it just makes not sense to me.

       

      Imagine you've got an 8" X 10" layout and want to cut the bottom 2 inches off the page to make an 8 X 8 square layout. That's all I'm trying to do :/

       

      I feel like I'm completely off track. Can somebody please explain in English what I should be doing to make this happen?

       

      Thanks

      D

       

      PS: I'm stuck in CS5 for this job.

        • 1. Re: Reducing page height
          Kasyan Servetsky Level 5

          Here is an example -- a script I wrote a while ago:

          // Copyright 2012, Kasyan Servetsky
          // July 24, 2012
          // Written by Kasyan Servetsky
          // http://www.kasyan.ho.com.ua
          // e-mail: askoldich@yahoo.com
          //======================================================================================
          const scriptName = "Crop Pages and export to PDF-file";
          const scriptVersion = "1.0";
          
          Main();
          
          //===================================== FUNCTIONS  ======================================
          function Main() {
              var width;
              if (app.documents.length == 0) ErrorExit("Please open a document and try again.");
              var doc = app.activeDocument;
              
              var xUnits = doc.viewPreferences.horizontalMeasurementUnits;
              var yUnits = doc.viewPreferences.verticalMeasurementUnits;
              doc.viewPreferences.horizontalMeasurementUnits = doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
              
              var bottomMargin = 28.346; // 10 mm
              
              for (var i = 0; i < doc.pages.length; i++) {
                  var page = doc.pages[i];
                  var pageBounds = page.bounds; // [y1, x1, y2, x2]
                  var pagePrefs = page.preferences;
                  var mainTextFr = page.textFrames[0];
                  var gb = mainTextFr.geometricBounds;
                  var bottom = gb[2] + bottomMargin;
                  
                  if (page.side == PageSideOptions.LEFT_HAND) {
                      width = pageBounds[3];
                  }
                  else {
                      width = pageBounds[3] - pageBounds[1];
                  }
          
                  page.resize(CoordinateSpaces.PASTEBOARD_COORDINATES, // in INNER_COORDINATES PASTEBOARD_COORDINATES
                                  AnchorPoint.TOP_LEFT_ANCHOR, // from
                                  ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH, // by
                                  [ width, bottom ]    ); // values
                  
                  var pdfFolder = new Folder("~/Desktop/Pdf/");
                  if (!pdfFolder.exists) pdfFolder.create();
                  var pdfFile = new File("~/Desktop/Pdf/" + doc.name.replace(/\.indd$/, "") +  "_" + page.name + ".pdf");
                  app.pdfExportPreferences.pageRange = page.name;
          
                  try {
                      var backgroundTask = doc.asynchronousExportFile(ExportFormat.PDF_TYPE, pdfFile, false, "[High Quality Print]");
                  }
                  catch(err) {
                      $.writeln(err.message + ", line: " + err.line);
                  }
              }
          
              doc.viewPreferences.horizontalMeasurementUnits = xUnits;
              doc.viewPreferences.verticalMeasurementUnits = yUnits
          }
          //--------------------------------------------------------------------------------------------------------------------------------------------------------
          function ErrorExit(error, icon) {
              alert(error, scriptName + " - " + scriptVersion, icon);
              exit();
          }
          //--------------------------------------------------------------------------------------------------------------------------------------------------------
          

          The script  "crops" the bottom of the page.