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

Problem with smart reflow in script

Community Expert ,
Jul 15, 2023 Jul 15, 2023

Copy link to clipboard

Copied

Having issues getting smart text reflow to work via script. I have a Parent Page with a primary text frame of "content." 

 

var buildSection = function(tf, dataObj, pageRef) {
  var pageToReturn = pageRef;  
  var parentStory = tf.parentStory;
  var currIP = parentStory.insertionPoints[-1];
  var key;
  for (key in dataObj) {
      //Do a bunch of text stuff, some of which yield overset text
  }
  if (tf.overflows) {    
    pageToReturn = doc.pages.add();
    pageToReturn.appliedMaster = pageRef.appliedMaster;
    pageToReturn.textFrames.itemByName("content").previousTextFrame = textFrame;
  }
  return pageToReturn;  
}


//main call looks like:
  doc.textPreferences.smartTextReflow = false;
  var currPage = somePage;
  for (s in sections) { 
     currPage = buildSection(currTf, dataObj, currPage);
  }
  doc.recompose();
  doc.textPreferences.properties = {
    smartTextReflow: true,
    deleteEmptyPages: true,
    limitToMasterTextFrames: false,
  }
  doc.recompose();

    

 

I'm working in single, not facing pages. I tried adding a second spread to the Parent Page and linking the two primary text frames, but still to no avail. Do I need to use facing pages for it to work? Is there something else I'm missing? Essentially I end up with several sets of pages, some have overflow content, some do not, all using the same parent page.  

TOPICS
Scripting

Views

91

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 15, 2023 Jul 15, 2023

Copy link to clipboard

Copied

Hi @brianp311, I have only had a quick look at your code, so it might be more than this, but I noticed that in this line:

pageToReturn.textFrames.itemByName("content").previousTextFrame = textFrame;

 "textFrame" is not defined. Should it be tf?

- Mark

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 16, 2023 Jul 16, 2023

Copy link to clipboard

Copied

And the TextFrame from the Master needs to be overriden first? 

 

ID-Tasker - most powerful tool ever created for InDesign

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 16, 2023 Jul 16, 2023

Copy link to clipboard

Copied

LATEST

Primary text frames override by default.

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 16, 2023 Jul 16, 2023

Copy link to clipboard

Copied

Thanks Mark. No, just a typo trying to synthesize larger code. Script executes properly. I'm left with two pages, two linked frames, but no smart reflow. 

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