Copy link to clipboard
Copied
There is a command to recompose all the stories. It is:
Ctrl + Alt + /
I want to invoke the same command using this method:
app.menuActions.item("$ID/Show Rulers").invoke();
Instead of "Show Rulers" how do I write the above command.
Thanks
Copy link to clipboard
Copied
You don't need a menu item.
app.activeDocument.stories.everyItem().recompose();
Though app.activeDocument.recompose() should work fine too
Copy link to clipboard
Copied
@brian_p_dts For some reason it is not working.
I have to run Ctrl Alt / to refresh the stories.
Copy link to clipboard
Copied
It is true that .recompose() doesn't always work. What sometimes helps is a good kick up the story's backside. The script version of the kick is to change the size of the story's first text frame, then set it back to the original. Something like this:
frame = myStory.textContainers[0];
gb = frame.geometricBounds;
// Make the frame 1 unit of whatever taller and wider
frame.geometricBounds = [gb[0], gb[1], gb[2]+1, gb[3]+1];
// Set it back to its original size
frame.geometricBounds = gb;
Rattling a frame like this usually works.
Copy link to clipboard
Copied
@Peter Kahrel Thanks for the reply.
I am getting error message on running the script:
"myStory is undefined".
I then added following line but to no avail:
myStory = app.activeDocument.stories;
After adding this line, I get following error message:
Error Number: 55
Error String: Object does not support the property or method 'textContainers'
Engine: main
File: C:\Users\shah\AppData\Roaming\Adobe\InDesign\Version 19.0-ME\en_AE\Scripts\Scripts Panel\recompose.jsx
Line: 15
Source: myframe = myStory.textContainers[0];
Copy link to clipboard
Copied
Yes, sorry, 'myStory' was just a generic variable name.
Do myStory = app.activeDocument.stories[0] (if the document has one story).
Or select a text frame and do myStory = app.selection[0].parentStory
And to process all stories in a document, do
function processStory (aStory) {
// Whatever
}
myStories = app.activeDocument.stories.everyItem().getElement();
for (i = 0; i < myStories.length; i++) {
processStory (myStories[i]);
}
Copy link to clipboard
Copied
@Peter Kahrel Thanks a lot.
Copy link to clipboard
Copied
There is a command to recompose all the stories. It is:
Ctrl + Alt + /
By @Bedazzled532
In addition to other suggestions, you can, probably, invoke this very shortcut via a script. I know how it's done in AppleScript (which is useless for you) but not in JS, but it must be possible in JS too.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now