1 Reply Latest reply on Mar 21, 2008 12:02 AM by Kasyan Servetsky

    HELP!!! Creating Text using script

    Level 1
      Hi there,

      I am writing a script which creates a text frame and adds text in it. The problem is, I want to add some information below everytime on many documents. Instead of copying from other sources everytime, I thought of writing a scirpt which by clicking creates a text frame and puts text in that because it is the same for all. Now two issues:
      1) It is coming but in the first page. I need that in the working page, for example clicking that it should come in page 2 or 4 and not in the first page.
      2) The text has a word should be in quotes giving like that the script shows error. My example code is given below:

      var myDocument = app.activeDocument;
      var myTextFrame = myDocument.textFrames.add()
      myTextFrame.geometricBounds = ["11.2in", "8in","10.99in","0.5in"];
      myTextFrame.contents = "This is a "sample" text.
      Please try without quotes first. Without quotes for sample word it is coming in the first page. With quotes it shows error.

      What is the solution. 1) need to add on the current working page. 2) should also include a word within quotes.

      Help really appreciated!
        • 1. Re: HELP!!! Creating Text using script
          Kasyan Servetsky Level 5
          Hi Prasant,

          1) Add a text frame to the active page
          2) Escape quotes in the string \"

          var myDocument = app.activeDocument;
          // Ruler origin should be set to Page
          myDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
          var myTextFrame = app.activeWindow.activePage.textFrames.add();
          myTextFrame.geometricBounds = ["11.2in", "8in","10.99in","0.5in"];
          myTextFrame.contents = "This is a \"sample\" text.";

          Kasyan