Copy link to clipboard
Copied
This is urgent guys, I need your help.
I have a document of more than 500 pages, some frames are threaded while others are not across the document. Each page has only one text frame completely filled in it. Now, I want to Thread them all together from page 1 to last. i.e. those threaded ones should remain threaded and any unthreaded in the middle of threaded should be thread together while maintaining chronological page order as it is from 1 to 500..
I have tried several script including textstich but Fail to thread them chronologically.
Please, someone should help with a script that would work.
Thanks
Copy link to clipboard
Copied
This will thread every frame together, from first to last page. Is that what you want?
var pages = app.activeDocument.pages.everyItem().getElements();
for (var i = 1; i < pages.length; i++) {
try {
pages[i].textFrames[0].previousTextFrame = pages[i -1].textFrames[0];
} catch(e) {}
}
Copy link to clipboard
Copied
Thanks brianp311 for the assistance.
Take a look at the result I have
Before
After Running the Script
It did the job, but take the unthreaded frames to the end of the document and merge the text in each of them together in a single frame.
But this is I aim to achieve
All frames should remain in their position and retain content (text and paragraph style) after threading
Observation
The document has more than 500 pages
Copy link to clipboard
Copied
Chronologically?
You mean page by page in order of your pages in the document, don't you?
And threaded stories should not be touched?
That script should do the job:
var textFrames = app.documents[0].pages.everyItem().textFrames[0].getElements();
var textFramesLength = textFrames.length;
var textFramesToThread = [];
// Get all text frames that should be threaded:
for( var n=0; n<textFramesLength; n++ )
{
// The story of the text frame has more than 1 text containers? Do nothing and loop on:
if( textFrames[n].parentStory.textContainers.length >1 ){ continue };
// Last character of story is not a end of paragraph character? Add one:
if
(
n+1 < textFramesLength &&
textFrames[n].parentStory.characters.length > 0 &&
textFrames[n].parentStory.characters[-1].contents != "\r"
)
{
textFrames[n].parentStory.insertionPoints[-1].contents = "\r";
};
// Add text frame to the array of text frames that should be stitched:
textFramesToThread[ textFramesToThread.length++ ] = textFrames[n];
};
// Thread the text frames:
for( var n=0; n<textFramesToThread.length-1; n++ )
{
textFramesToThread[n].nextTextFrame = textFramesToThread[n+1];
};
Before running the script:
After:
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Thanks Laubender for the assistance.
Take a look at the result I have, it is similar to that of brianp31 above.
Before
After Running the Script
It did the job, but take the unthreaded frames to the end of the document and merge the text in each of them together in a single frame.
But this is what I aim to achieve
All frames should remain in their position and retain content (text and paragraph style) after threading
Observation
The document has more than 500 pages
Copy link to clipboard
Copied
Aha. There is news.
Retain contents could be tough when threading text frames of unknown contents and size.
Hm. I wonder why the frames should be threaded at all, if contents should be retained.
You could work my script on your document after you first split all threaded stories in the document.
For that purpose use Ariel Walden's script BreakTextThread.jsx that can be found in the Community folder of your InDesign Scripts panel with InDesign 2020 and 2021.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Thanks, it worked after breaking all frames and threading again