13 Replies Latest reply on Aug 3, 2015 5:24 AM by mani@pixel

    how to add caption for all images in indesign document using indesign javscript

    mani@pixel

      i want to add caption for all the images in indesign document..

      this is my code .. im getting error like ,

      invalid parameter.

       

      capset ();

       

       

      function capset()

      {

      var doc = app.activeDocument;

      var myPicture = doc.allGraphics;

      var gb,i, myCaption;

      while(pic = myPicture.pop() )

      {  

      gb= pic.geometricBounds;

      // add a frame to to picture's parent, which is a Page

      myCaption = pic.parent.textFrames.add ();

      // set position and size of the caption

      myCaption.geometricBounds = [gb[2], gb[1], gb[2]+3, gb[3]];

      // add placeholder contents

      myCaption.contents = "Caption";

      pic.parent.groups.add ([pic, myCaption]);

      }

      }