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.
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
Copy link to clipboard
Copied
And the TextFrame from the Master needs to be overriden first?
Copy link to clipboard
Copied
Primary text frames override by default.
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.