• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Populating a document with master pages and input from a UI

Community Expert ,
Jul 08, 2018 Jul 08, 2018

Copy link to clipboard

Copied

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+"\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

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
TOPICS
Scripting

Views

352

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 08, 2018 Jul 08, 2018

Your script finds the 'begin' frame on the master before any others. So you could do

myDoc.pages[0].textFrames.item("begin")

to get the one on the document page, not the master page.

To fill that whole story, no need to iterate through the array. Just do this:

myDoc.pages[0].textFrames.item("begin").contents = d.join('\r')

Peter

Votes

Translate

Translate
Community Expert ,
Jul 08, 2018 Jul 08, 2018

Copy link to clipboard

Copied

Your script finds the 'begin' frame on the master before any others. So you could do

myDoc.pages[0].textFrames.item("begin")

to get the one on the document page, not the master page.

To fill that whole story, no need to iterate through the array. Just do this:

myDoc.pages[0].textFrames.item("begin").contents = d.join('\r')

Peter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

LATEST

Thank you for that Peter, that worked a charm.

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines