Skip to main content
February 3, 2018
Answered

Remove Auto-Size on all text frames within a document?

  • February 3, 2018
  • 4 replies
  • 2315 views

..is there a way to have a one move script to remove auto-sizing on all text frames within an indesign document without selecting the text frames manually?

I personally use auto-sizing for color names and keys when building catalog spreads, but some designers at work complain about it *eye rolls*...so I want to give them a script to alleviate their ‘pain.’

As always any feedback is much appreciated.

Cheers.

This topic has been closed for replies.
Correct answer Laubender

Hi Neal,

this one should do it:

var doc = app.documents[0];
var allTextContainers = [];

var allStories = doc.stories.everyItem().getElements();
var allStoriesLength = allStories.length;

for(var n=0;n<allStoriesLength;n++)
{
	allTextContainers = 
	allTextContainers.concat( allStories[n].textContainers );
};

var allTextContainersLength = allTextContainers.length;

for(var n=0;n<allTextContainersLength;n++)
{
	if( allTextContainers[n].constructor.name == "TextPath" )
	{ continue };

	allTextContainers[n].textFramePreferences.autoSizingType = 
	AutoSizingTypeEnum.OFF;
};

 

CODE EDITED Feb 6, 2020

Why? Because the transfer of this thread to the new Adobe InDesign Forum damaged the code.

 

Regards,
Uwe Laubender

( ACP )

4 replies

Participating Frequently
July 21, 2023

Thanks-you, I'm one of THOSE designers (Art-Director actually) who can't stand the Auto resize. It has it's uses, but my designers use this everywhere!!! and if I have to correct thir layout due to bad aesthetiques. it is AMAZINGLY annoying.

jorgen_brynhildsvoll
Participant
February 6, 2020

Hi, Uwe! I think I have used this script successfully before. Now, when I try to run it, I get an "Undefined is not an object" error. Do you know what causes this?

Community Expert
February 6, 2020

Hi Jorgen,

thank you for your reply. Now I edited the code to something more reasonable.

The transfer of this thread to the new Adobe InDesign Forum damaged the code!

 

Regards,
Uwe Laubender

( ACP )

February 3, 2018

..I just accomplished this by piggy backing off a resize script I had previously and came up with the following that worked.

  1. /* Turn off auto-size on all text frames within a document
  2. Neal Derek Lawson via snippets from Adobe Forums
  3. */
  4. var doc=app.documents[0];
  5. var po=doc.pageItems;
  6. for (var i=po.length-1; i>=0; i--) {
  7. po.textFramePreferences.autoSizingType=AutoSizingTypeEnum.OFF;
  8. };
Community Expert
February 3, 2018

Hi Neal,

your script will only work with documents where all first level pageItems are text frames ( text frames that are drawn directly to a spread ).

Add one single rectangle to a page and your code will throw an error, because a rectangle has no property textFramePreferences.

Also: Nested text frames e.g. in groups or anchored text frames will not be reached.

Regards,
Uwe

February 3, 2018

Yes, I gathered that soon after replying.

It would have taking me forever, to fashion the end result, after running into those hurdles, i.e. graphic frames, groups, nested/anchors, etc.

I appreciate the speed boost and the accounting for all those obstacles.

One thing, how do you post your code with the formatting I see everyone using (vertical grey/green bar, with white and grey rows, and the code font, etc)?

Thanks again man.

February 3, 2018

So far I have the below script that removes auto-size to only one instance of a text frame within a document with many instances of a text frame sporting auto-sizing.

So how can I ‘loop?’ the script to catch every text frame with auto-size on the document and turn it to off?

As always thanks in advance for any feedback....cheers.

  1. var doc=app.documents[0];
  2. var po=doc.pageItems[0];
  3. //copy
  4. var txt=po.textFramePreferences.autoSizingType =
  5. AutoSizingTypeEnum.OFF;
  6. //var txt=po.textFrames.add();
  7. //txt.visibleBounds=po.visibleBounds;
  8. //txt.contents="1";
  9. //txt.paragraphs[0].justification=1667591796 ;
  10. /*
  11. myFrame.textFramePreferences.autoSizingType =
  12. AutoSizingTypeEnum.HEIGHT_ONLY;
  13. */
LaubenderCommunity ExpertCorrect answer
Community Expert
February 3, 2018

Hi Neal,

this one should do it:

var doc = app.documents[0];
var allTextContainers = [];

var allStories = doc.stories.everyItem().getElements();
var allStoriesLength = allStories.length;

for(var n=0;n<allStoriesLength;n++)
{
	allTextContainers = 
	allTextContainers.concat( allStories[n].textContainers );
};

var allTextContainersLength = allTextContainers.length;

for(var n=0;n<allTextContainersLength;n++)
{
	if( allTextContainers[n].constructor.name == "TextPath" )
	{ continue };

	allTextContainers[n].textFramePreferences.autoSizingType = 
	AutoSizingTypeEnum.OFF;
};

 

CODE EDITED Feb 6, 2020

Why? Because the transfer of this thread to the new Adobe InDesign Forum damaged the code.

 

Regards,
Uwe Laubender

( ACP )

February 3, 2018

Ha...I think I’ll go with your script just the same.

The one I fashioned together works, but something tells me yours might catch more variables, i.e. unknown situations.

In any case I have both scripts on hand that both deliver the same results so far.

Thanks man, I really appreciate it.

Cheers.