0 Replies Latest reply on Mar 17, 2015 9:48 AM by lister110

    executing a script [listener] on document size changes - like a variable

    lister110 Level 1

      I would like to use variable to populate a text box with the document size, but Im not sure this is possible yet… so I've found a script which can be applied to a text frame and be executed through the scripts panel. But I was wondering if its possible a script can use something like an event listener to re-populate a text frame each time I change the document size. here is the code so far, thanks to the link Textvariable page size?

       

      myDoc = app.activeDocument;
      myPages = myDoc.pages.everyItem().getElements();
      mhV = myDoc.viewPreferences.horizontalMeasurementUnits;
      mvV = myDoc.viewPreferences.verticalMeasurementUnits;
      myDoc.viewPreferences.horizontalMeasurementUnits = myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;
      
      for (var k = 0; k < myPages.length; k++) {
          resString = mySize(myPages[k]);
          resFrame = myFrame(myPages[k]);
          resFrame.contents = resString;
          }
      
      myDoc.viewPreferences.horizontalMeasurementUnits = mhV;
      myDoc.viewPreferences.verticalMeasurementUnits = mvV;
      
      function mySize (page) {
          var Pbound = page.bounds;
          var pH = Pbound[2] - Pbound[0];
          var pW= Pbound[3] - Pbound[1];
          var res = (Math.round(pH*100)/100).toString() + "mm(H) x " + (Math.round(pW*100)/100).toString() + "mm(W)";
          return res;
          }
      
      function myFrame (page) {
          var mF = page.textFrames.itemByName("pagesize");
          var arrSize = [62,30];
          return mF;
          }
      
      

       

       

      (Label a text frame called pagesize in indesign)

       

       

       

      can anyone help..

       

      lister