Yeap,
The problem is only you can see how it appears. I can just read what you wrote, nothing else.
You shouldn't ask for "re-threading" frames if your goal is to recompose text. There are different stories.
I gave you a code to step back from a mistake you wrote about.
To reach a goal with recomposing I suggest workflow like:
- duplicate a doc
- remove main story
- link frames as page order
- duplicate particular texts page by page from original doc to a copy
Assuming 3 steps are done - 4th depends on your doc structure (how many frames on page, how to detect a proper textFrame, is it named?)
Lets assume you did an empty copy with textFrame linked in page order and there is only one frame per page and a story starts from 1st page.
Keep source and output opened and activate a source. Then run this:
var
sourceDoc = app.activeDocument,
outputDoc = app.documents[1],
myTextArray = sourceDoc.pages.everyItem().textFrames.everyItem().texts.everyItem().getElements();
for (var k=0; k<myTextArray.length; k++)
myTextArray.duplicate(LocationOptions.AFTER, outputDoc.pages[0].textFrames[0].parentStory.texts[0] );
Jarek
I’m not sure, if I understand the goal correctly and we talk about the same things if we talk about recomposing or re-threading.
I would do the following:
1. Use Adobes script split story. This will duplicate all Frames and delete the origin story
2. Re-Thread the frames in the order as shown on the document pages
3. To prevent any other frames on the page, give the frames before re-threading or recomposing ;-) a name
// check selection
if ( !( app.selection.length == 1 && ( app.selection[0].hasOwnProperty('baseline') || app.selection[0].constructor.name == "TextFrame" ) )) {
alert( "wrong selection!" );
exit();
}
var curStory = app.selection[0].parentStory;
var curDoc = app.activeDocument;
if ( curStory.textContainers.length > 1 ) {
mySplitStory( curStory );
myRemoveFrames( curStory );
}
relinkTextFrames ( curDoc.textFrames );
function mySplitStory( myStory ) {
var myTextFrame;
//Duplicate each text frame in the story.
for( var myCounter = myStory.textContainers.length-1; myCounter >= 0; myCounter -- ) {
myTextFrame = myStory.textContainers[myCounter];
myTextFrame.name = "linkme";
myTextFrame.duplicate();
}
}
function myRemoveFrames( myStory ) {
//Remove each text frame in the story. Iterate backwards to avoid invalid references.
for( var myCounter = myStory.textContainers.length-1; myCounter >= 0; myCounter -- ) {
myStory.textContainers[myCounter].remove();
}
}
function relinkTextFrames( myTextFrames ) {
var collectTFrames = [];
for (var i = 0; i < myTextFrames.length; i++ ) {
if ( myTextFrames.name == "linkme" ) {
collectTFrames.push(myTextFrames);
}
}
for ( var n = 0; n < collectTFrames.length-1; n++ ) {
var curTFrame = collectTFrames;
var nextTFrame = collectTFrames[n+1];
curTFrame.nextTextFrame = nextTFrame;
}
}