2 Replies Latest reply on Aug 15, 2008 8:25 PM by hm_arul

    Space fixing graphic and graphic caption

    hm_arul
      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 graphic caption frame is not creating to the full text width.

      I want to create the graphic caption to full text width. Any one advice me where I am wrong in this script

      #target indesign
      var myDocument= app.activeDocument;
      with (myDocument)
      {
      var myPage = pages.item(0);
      }
      with (myDocument.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:\ra photograph and a caption.' );
      exit()
      } caption_space = 3.4;
      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-mar;
      //alert(mywidth)
      //caption.geometricBounds = [ pb[2]+caption_space, pb[1], pb[2]+200, pb[3] ];
      caption.geometricBounds = [pb[2]+caption_space, myX1, pb[2]+200, mywidth];
      caption.fit (FitOptions.frameToContent);

      since the main part of the script I copied from adobe forums, I cant get what's the unit value in this line?

      caption_space = 3.4;

      3.4 referes which unit its mm? point? or something else?

      Thanks in advance

      regards
      a r u l
        • 1. Re: Space fixing graphic and graphic caption
          csm_phil Level 4
          Hi Arul Machi,

          I clear the error in ur script...

          check it and Let me know if any suggestion of queries....

          Okay

          regards
          Baby.......

          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()
          } caption_space=11;
          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;
          //You made mistaken this place you minus only right margin only indication is (-myX2)
          var mywidth = myPageWidth-myX2;
          caption.geometricBounds = [pb[2]+caption_space, myX1, pb[2]+200, mywidth];
          caption.fit (FitOptions.frameToContent);
          //alert("Complted.....!")
          • 2. Re: Space fixing graphic and graphic caption
            hm_arul Level 1
            great machi u done it da

            thanks

            regards
            a r u l