2 Replies Latest reply on Jul 9, 2018 7:33 PM by Colin Flashman

    Populating a document with master pages and input from a UI

    Colin Flashman Adobe Community Professional

      Hi all.

       

      I have a user interface that generates a list of dates based on start/end points entered by the user. I'd like it to populate an InDesign template that I've made:

      start.png

      I've assigned the first frame on the master page with the name "begin".

       

      The code I'm using to call the template and populate the text fields are as follows:

       

      var myDoc = app.open ("--REDACTED LOCATION--:testdiary.indd");
      while (h < d.length) {
      myDoc.textFrames.item("begin").contents += ""+d[h]+"\r";
      h++}
      

       

      Once I run the script, it finishes with three problems:

      1. The type is all on the master pages, not on the normal pages;
      2. The type has not flowed onto more pages but is still stuck on the two page spread in the template;
      3. The text is not in the right order it was created in. The first six lines are fine, but as soon as the type jumps to the next text box, everything is entered in reverse order.

      As shown in this example:

      end.png

      Until now, my scripting knowledge so far hasn't seen me creating any large scale text documents like this, so this is all new to me. My research so far into this topic talks about generating the text frames as the script goes and basing the next text frame off of geometric locations, but I can't find any documentation into trying to populate text frames in an existing template.

       

      Clearly I'm doing something incorrectly, have missed some steps, or have made a pig's ear of the whole thing. Is anyone able to talk me through what I'm doing wrong and what I should do next?

       

      Colin