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

Problem with smart reflow in script

Community Expert ,
Jul 15, 2023 Jul 15, 2023

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
280
Translate
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

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

Translate
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

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

 

Translate
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
LATEST

Primary text frames override by default.

Translate
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

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. 

Translate
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