4 Replies Latest reply on Aug 21, 2008 3:30 AM by Glen_Bal

    Placing Textframes

    Glen_Bal Level 1

      I'm pretty new to indesign (scripting) and i'm puzzled.
      I want a textframe at the bottom of each page, of course different for recto and verso. But because i have many different masterpages and masterspreads, i don't want to add a textframe on each masterpage/spread.
      I quickly made a little code to put a textframe on page 2 and 3. page 2 and 3 are on the same spread.

      var myDocument = app.documents[0];
      for (cPages = 1; cPages < 3; cPages++) {
      var myTextFrame = myDocument.pages[cPages].textFrames.add();
      myTextFrame.geometricBounds = ["2p","6p","20p","15p"];
      myTextFrame.insertionPoints.item(0).contents="this is my text";

      What happens: I have 2 textframes on page 2 at the same position and none on page 3. So for textframes-reference it takes the spread insteed of the page, and i don't seem to get it right.

      Question 1: What is the way to do what i want?
      Question 2: How can i change the referencepoint of the textframe?

      Thanks for your answers.
      (I hope my questions aren't too stupid)

        • 1. Re: Placing Textframes
          Glen_Bal Level 1
          Answer to Question 2:
          You can't change the referencepoint of the textframe, you can only change the referencepoint of the document or application with layoutWindows[0].transformReferencePoint.

          That leaves Question 1 still open
          • 2. Re: Placing Textframes
            [Jongware] Most Valuable Participant
            You're actually going along just fine. This is just one of ID's little inside jokes.

            Changing the Reference point will not help you here; that's the point around which objects are rotated, the same as the transform proxy in the top left of your control panel.
            What you want is to change the way the rulers are set up: not going all the way from the left page to the right, but starting over on each page. If you never seen that before, right-click the top ruler, and you will see that your current setting is "Ruler per Spread". Now, you can either change it to "Ruler per Page" in the interface, or -- the scripter's way of working --
            i save
            the current setting (whatever it is), change it to 'per page', do your stuff, then change it back to its original value.

            How about something like

            oldViewPref = app.activeDocument.viewPreferences.rulerOrigin;
            app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
            .. (your script here) ..
            app.activeDocument.viewPreferences.rulerOrigin = oldViewPref;
            • 3. Re: Placing Textframes
              Peter Kahrel Adobe Community Professional & MVP

              Remove the line "myTextFrame.geometricBounds = ["2p","6p","20p","15p"];" and you'll see that the frames are placed on the correct pages. That means that you have your rulers set to "per spread", so that your geometricBounds always point to the same point on the spread.

              Set your rulers to "per page" and the textframes will be placed on the correct page:

              myDoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;


              [jong beat me to it!]
              • 4. Re: Placing Textframes
                Glen_Bal Level 1
                Thank you guys! Another puzzle solved :-)

                I hope one day I can give an answer to a question i'm not asking myself