Copy link to clipboard
Copied
Hi everyone!
Anyone knows how to link all the text frames (Thread) in document and what is the best way to do that?
Can I create the text frames on master spread and then link all of the the in the document? Or should I create the directly on the document pages?
And before that, how can I link all of them?
Thanks in advance!
There are a few problems with Sunil's script. The error you got was caused by the fact that allPages is a collection, and collections don't have the textFrame property.
If the conditions are the same as Sunil assumed (a single text frame on each page), you can use this code:
pages = app.documents[0].pages.everyItem().getElements();
thread = pages[0].textFrames[0];
for (i = 1; i < pages.length; i++) {
thread.endTextFrame.nextTextFrame = pages[i].textFrames[0];
}
P.
Copy link to clipboard
Copied
Hello diogo,
If your document has multiple pages and each pages has only single text frame of size of type area.
Assuming this, you can use this below code to link these textFrames as follows:
//// Assuming Every Page has only one main textFrame ---
var myDoc = app.documents[0];
var allPages = myDoc.pages;
var currentFrame = allPages[0].textFrames[0];
for(var i = 1; i < allPages.length; i++){
currentFrame.nextTextFrame = allPages.textFrames[i];
currentFrame = allPages.textFrames[i];
}
Best
Sunil
Copy link to clipboard
Copied
Hi,
this would save my life.
I'm on the latest Indesign version and unfortunately I'm getting this error: "object does not support the property or method 'textFrames'" on string 6 'currentFrame.nextTextFrame = allPages.textFrames[i];'
Please help!
Copy link to clipboard
Copied
There are a few problems with Sunil's script. The error you got was caused by the fact that allPages is a collection, and collections don't have the textFrame property.
If the conditions are the same as Sunil assumed (a single text frame on each page), you can use this code:
pages = app.documents[0].pages.everyItem().getElements();
thread = pages[0].textFrames[0];
for (i = 1; i < pages.length; i++) {
thread.endTextFrame.nextTextFrame = pages[i].textFrames[0];
}
P.
Copy link to clipboard
Copied
That's just perfect, it helped me big time!
Thank you so so much,
EL
Copy link to clipboard
Copied
Hello Peter, how do I modify the script for two text frames on each page? If there's more than one only every second frame is linked.
Copy link to clipboard
Copied
Never mind, Peter. I searched a little more and found this free script that does the job. https://www.rorohiko.com/wordpress/indesign-downloads/textstitch/
Copy link to clipboard
Copied
Hi peter, 2 years later... is still there a way to make it work?
Thank You!
Copy link to clipboard
Copied
You'll have to provide some more detail. For example, do you have a single text frame on each page?
Copy link to clipboard
Copied
Thank you!
Yes.
Ok now I see the issue...
It dos'nt work when there is some threads
(Every two frames are concatenated together, there are a lot of separated such pairs in the document, I need them all in one long thread.
When I left only 4 pages and disconnected them completely - only then the script works)
Is there a way to make the script work even when some frams are threaded?
Copy link to clipboard
Copied
In other words:
Can a script go over the document and combine it into one thread?
Let's say I have ten chapters, and I broke threads in each chapter (using the 'BreakTextThread' script) to make the document faster, and now I want to connect everything back together.
Assuming there is one text frame per page, or mabe better - in a specific object style there is only one text frame in page
Is this possible using a script?
Copy link to clipboard
Copied
Sure. At the first line of the script enter the name of the object style.
ostyleName = 'Xyz';
sortedStories = [];
stories = app.documents[0].stories.everyItem().getElements();
for (i = 0; i < stories.length; i++) {
if (stories[i].textContainers[0].appliedObjectStyle.name === ostyleName) {
sortedStories.push (stories[i]);
}
}
// An expensive sorter...
sortedStories.sort (function (a, b) {
return a.textContainers[0].parentPage.documentOffset
- b.textContainers[0].parentPage.documentOffset;
});
for (i = sortedStories.length-1; i > 0; i--) {
sortedStories[i-1].textContainers[0].endTextFrame.nextTextFrame =
sortedStories[i].textContainers[0];
}
Copy link to clipboard
Copied
hmmm this doesn't work anymore today. these are .js scripts right?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Otherwise only if you want to link two frames,
you can use this code.
firstTextFrame.nextTextFrame = secondTextFrame;
Best
Sunil