0 Replies Latest reply on Aug 18, 2008 9:47 PM by hm_arul

    Figure and caption space fixing

    hm_arul Level 1
      Hi scripters

      Here I am trying to fix space between graphic and graphic caption to 18pts(b/b). Below is the script, it's working good. But I have problem with above space for graphic caption frame.

      I get in input value using prompt command, while I am converting prompt value into varibale space it's not working!

      here is my script

      var myDoc= app.activeDocument;
      var myDoc = app.activeDocument;
      myDoc.viewPreferences.rulerOrigin=RulerOrigin.spineOrigin;
      myDoc.viewPreferences.horizontalMeasurementUnits=MeasurementUnits.points;
      myDoc.viewPreferences.verticalMeasurementUnits=MeasurementUnits.points;
      var myPage = myDoc.pages.item(0);
      with (myDoc.documentPreferences){
      var myPageHeight = pageHeight;
      var myPageWidth = pageWidth;
      }
      with(myPage.marginPreferences){
      var myX1 = left;
      var myY1 = top;
      var myY2 = bottom;
      var myX2 = right;
      }
      if( app.selection.length != 2 )
      {
      alert( 'Select two objects:\r A Photograph & Caption...' );
      exit()
      }

      var caption_space = prompt ('Give visual white space between figure and caption', '18', 'Figure and caption align');
      //var a = new UnitValue(caption_space);
      //a.convert("pt");
      //alert(a+0);

      if( app.selection[0].constructor.name == 'Rectangle' )
      {
      picture = app.selection[0];
      caption = app.selection[1];
      }
      else
      {
      picture = app.selection[1];
      caption = app.selection[0]
      }
      pb=picture.geometricBounds;
      var mar = myX1+myX2;
      var mywidth = myPageWidth-myX2;

      caption.geometricBounds = [pb[2]+caption_space, myX1, pb[2]+200, mywidth];
      caption.fit (FitOptions.frameToContent);

      Please advice me how to tell script to add value of caption_space?

      thanks in advance

      regards
      a r u l