Copy link to clipboard
Copied
This is getting to be really frusting. I have enabled smart text flow, it only works if I open the app and modify a textframe. It never works when I run it through a script????? How do I activate this stupid feature using a script?
Copy link to clipboard
Copied
Hi,
This works (for me):
var document = app.activeDocument;
var textFrame = document.textFrames.add();
var page = document.pages.add();
var nextTextFrame = page.textFrames.add();
document.textPreferences.smartTextReflow = true;
document.textPreferences.limitToMasterTextFrames = false;
document.textPreferences.deleteEmptyPages = true;
document.textPreferences.addPages = AddPageOptions.END_OF_DOCUMENT;
textFrame.geometricBounds = [10, 10, 280, 200];
nextTextFrame.geometricBounds = [10, 10, 280, 200];
nextTextFrame.previousTextFrame = textFrame;
for(var index = 0; index < 100; index++)
{
textFrame.contents += "Hello InDesign World Hello InDesign World Hello InDesign World Hello InDesign World Hello InDesign World Hello InDesign World Hello InDesign World ";
}
Copy link to clipboard
Copied
Why do you want to activate it if it's so stupid?
Peter
Copy link to clipboard
Copied
I adjusted the script above to this to show you that it doesn't work (the deleting part of smart text reflow does not work cause it's delayed)
var document =app.documents.add();
document.textPreferences.smartTextReflow = true;
document.textPreferences.limitToMasterTextFrames = false;
document.textPreferences.deleteEmptyPages = true;
document.textPreferences.addPages = AddPageOptions.END_OF_DOCUMENT;
for(var index = 0; index < 10; index++)
{
var page = document.pages.add();
var page2 = document.pages.add();
var textFrame = page.textFrames.add();
var nextTextFrame = page2.textFrames.add();
textFrame.geometricBounds = [10, 10, 40, 40];
nextTextFrame.geometricBounds = [10, 10, 40, 40];
nextTextFrame.previousTextFrame = textFrame;
textFrame.contents = "asdasD";
textFrame.recompose();
}
Run the script above and you'll see the delete part does not work. It will have empty pages that should be deleted. These empty pages will ONLY be deleted when Indesign is idle OR you manually resize the text frame in the indesign app (not script).
Is this a bug?
Copy link to clipboard
Copied
I think you're missing the point. You should not add pages in the loop. The smart text reflow does the adding for you (when there is text overflow).
Copy link to clipboard
Copied
Smart text reflow ONLY (per textframe) IF at least 2 text frames are threaded together (documentation). I'm adding the second page and a textframe and then linking this textframe to the first page textframe (so smart text flow will work). Each page will have an extra page associated with it so that smart text reflow works (basically, the additional page works as a placeholder....for overset text). If there is no overset text on a particular "even" ("first") page, then smart text reflow should automatically delete the extra page associated with it (the placeholder page). It will ONLY do this randomly/when indesign is idle. If you manually force it by using quick apply > recompose all stories immediately, it works immediately. Using textframe.recompose or document.recompose DOES NOT fix this problem. I noticed that the more the document had pages, the more time it took smart text reflow to trigger (unless you use the quick apply method).
This issue is in the Desktop, I don't know if Server has the same issue (can someone with server try smart text reflow and see if it deletes the pages? try using the recompose method on the server as well).