Skip to main content
brian_p_dts
Community Expert
Community Expert
July 16, 2023
Question

Problem with smart reflow in script

  • July 16, 2023
  • 1 reply
  • 380 views

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.  

This topic has been closed for replies.

1 reply

m1b
Community Expert
Community Expert
July 16, 2023

Hi @brian_p_dts, 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

Robert at ID-Tasker
Legend
July 16, 2023

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

 

brian_p_dts
Community Expert
Community Expert
July 16, 2023

Primary text frames override by default.