2 Replies Latest reply on Mar 4, 2008 10:35 AM by (Olav_Kvern)

    InDesign CS3 JS

    JADarnell Level 1
      I admit I am simply trying to understand JS for InDesign.

      I have written this small script to try out a few things:

      or(a = 0; a < NumberOfPages; a++)
      apage = app.activeDocument.pages.item(a);
      $.writeln("The page: ", apage.name);

      myPageItems = apage.pageItems;
      NumberOfItems = myPageItems.length;
      for(b = 0; b < NumberOfItems; b++)
      apageitem = myPageItems.item(b);

      pageItemName = apageitem.constructor.name;
      $.writeln("Page item name: ", pageItemName);
      $.writeln("Number of items: ", myPageItems.length);


      What I am trying to do is determine what kind of object each item is. The ultimate goal of this playing is to someday write a script that searches through a document for all items that use a particular color. Rectangles will require a different, simpler approach than a text frame,and I am sure there are other differences that I will have to account for. So I need to know which is which as I go through the page item list.

      With the above code, however, I am getting "PageItem" as the constructor.name for each item even though some are rectangles, and some are text boxes.

      So how do I get the correct value?