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

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

Guest
Feb 03, 2018 Feb 03, 2018

..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.

TOPICS
Scripting
2.0K
Translate
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

correct answers 1 Correct answer

Community Expert , Feb 03, 2018 Feb 03, 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 };

	allTextCont
...
Translate
Guest
Feb 03, 2018 Feb 03, 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. */
Translate
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 ,
Feb 03, 2018 Feb 03, 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 )

Translate
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
Guest
Feb 03, 2018 Feb 03, 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.

Translate
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
Guest
Feb 03, 2018 Feb 03, 2018

Also, how do you get your code posted here formatted in that easier to read fashion with the numbers and the green and grey lines, etc?

Thanks again.

Translate
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
Guest
Feb 03, 2018 Feb 03, 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. };
Translate
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 ,
Feb 03, 2018 Feb 03, 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

Translate
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
Guest
Feb 03, 2018 Feb 03, 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.

Translate
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 ,
Feb 03, 2018 Feb 03, 2018

Hi Neal,

for code formatting enable the Advanced Editor feature when answering in the forums.

Select your code you copied over, go to >> Insert > Syntax Highlighting > javascript

Regards,

Uwe

Translate
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
Guest
Feb 09, 2018 Feb 09, 2018

...thanks so much.

Cheers.

Translate
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
New Here ,
Feb 06, 2020 Feb 06, 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?Skjermbilde 2020-02-06 kl. 13.28.45.jpg

Translate
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 ,
Feb 06, 2020 Feb 06, 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 )

Translate
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 Beginner ,
Jul 21, 2023 Jul 21, 2023
LATEST

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.

Translate
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