• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How Auto Thread Text Frames

Explorer ,
Apr 26, 2021 Apr 26, 2021

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

TOPICS
Scripting

Views

455

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 27, 2021 Apr 27, 2021

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) {}

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

Thanks brianp311 for the assistance.

 

Take a look at the result I have

 

Before

1.PNG

 

After Running the Script

2.PNG

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

3.PNG

All frames should remain in their position and retain content (text and paragraph style) after threading

 

Observation

The document has more than 500 pages

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 27, 2021 Apr 27, 2021

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:

StitchTextFramesByPages-1.PNG

 

After:

StitchTextFramesByPages-2.PNG

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 27, 2021 Apr 27, 2021

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

1.PNG

 

After Running the Script

2.PNG

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

3.PNG

All frames should remain in their position and retain content (text and paragraph style) after threading

 

Observation

The document has more than 500 pages

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 27, 2021 Apr 27, 2021

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 )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

LATEST

Thanks, it worked after breaking all frames and threading again

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines