3 Replies Latest reply on Sep 30, 2009 6:42 AM by Urban L

    Add textFrame on each page of document

    Urban L

      I've been trying to write a JavaScript script to add a textframe on each page of a document.


      The script is wrote is:

      var myDocument = app.activeDocument;


      for (var pageCounter = 0; pageCounter < myDocument.pages.length; pageCounter ++) {
        //Create a text frame on page pageCounter
        var myTextFrame = myDocument.pages.item(pageCounter).textFrames.add();
        //Set the bounds of the text frame
        myTextFrame.geometricBounds = ["60p", "22p", "65p", "40p"];
        //Enter text in the text frame.
        var pageCounterPlus1 = pageCounter + 1;
        myTextFrame.contents = "Page " + pageCounterPlus1 + " of " + myDocument.pages.length}


      In my 5 page document, the script is putting one textframe on page 1, 2 on page 2 and 2 and page 4, but omits pages 3 and 5.

      My guess is that it's something about two-page spreads, but I don't know how to fix it.


      Any suggestions?




      Urban Landreman