Highlighted

Mass Edit Paragraph Styles Options

Engaged ,
Nov 01, 2020

Copy link to clipboard

Copied

Hi, 

I have many paragraph styles, and I try to apply mass changes to all in the panel "Paragraph Styles Options", to change the language, maximun word spacing, etc...

 

Please can you see why my script doesn't work?

var myDoc = app.activeDocument;
ParaStyle_Reduce();
//alert("Process Completed...");

function ParaStyle_Reduce(){
	var countAllParagraphStyles = myDoc.allParagraphStyles.length;	//simple counter to indicate the progress on Javascript console
	$.writeln("countAllParagraphStyles: " + countAllParagraphStyles);
	for(var a=0;a<myDoc.allParagraphStyles.length;a++){	
		$.writeln("a: " + a);
		try{
			// MENU PARAGRAPH STYLE OPTION - Advance Character Formats
			myDoc.allParagraphStyles[a].horizontalScale = 100;
			myDoc.allParagraphStyles[a].verticalScale = 100;
			myDoc.allParagraphStyles[a].baselineShift = 0;
			myDoc.allParagraphStyles[a].skew = 0;
			myDoc.allParagraphStyles[a].appliedLanguage = "Spanish";
			

			// MENU PARAGRAPH STYLE OPTION - Justification
			myDoc.allParagraphStyles[a].minimumWordSpacing = 85;
			myDoc.allParagraphStyles[a].minimumLetterSpacing = -2;
			myDoc.allParagraphStyles[a].minimumGlyphScaling = 97;
			myDoc.allParagraphStyles[a].desiredWordSpacing = 100;
			myDoc.allParagraphStyles[a].desiredLetterSpacing = 0;
			myDoc.allParagraphStyles[a].desiredGlyphScaling = 100;
			myDoc.allParagraphStyles[a].maximumWordSpacing = 110;
			myDoc.allParagraphStyles[a].maximumLetterSpacing = 2;
			myDoc.allParagraphStyles[a].maximumGlyphScaling = 103;
			myDoc.allParagraphStyles[a].autoLeading = 120;
			myDoc.allParagraphStyles[a].singleWordJustification = SingleWordJustification.FULLY_JUSTIFIED;
			myDoc.allParagraphStyles[a].composer = "Adobe Paragraph Composer";

			// MENU PARAGRAPH STYLE OPTION - Justification
			// myDoc.allParagraphStyles[a].hyphenation = true;
			myDoc.allParagraphStyles[a].hyphenateWordsLongerThan = 5; 		// (range 3 - 25) also the name of this value is Words with at Least
			myDoc.allParagraphStyles[a].hyphenateAfterFirst	= 2;				
			myDoc.allParagraphStyles[a].hyphenateBeforeLast = 2;
			myDoc.allParagraphStyles[a].hyphenateLadderLimit = 2; 	// (range 0 - 25) also the name of this value is Hyphen Limit
			myDoc.allParagraphStyles[a].hyphenationZone = 0;
			myDoc.allParagraphStyles[a].hyphenWeight = 2;	// (range 0 - 10) also the name of this value is Better Spacing and Fewer Hyphens
			myDoc.allParagraphStyles[a].hyphenateCapitalizedWords = false;
			myDoc.allParagraphStyles[a].hyphenateLastWord = false;
			myDoc.allParagraphStyles[a].hyphenateAcrossColumns = false;

			$.writeln("Progress: " + a + " of " + countAllParagraphStyles + " Styles");  //simple counter to indicate the progress on Javascript console
		}catch(e){}
	}
}

 

thanks so much in advance!

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi Manuel,

the only property you are using that is not independent of the installed InDesign localized version is the value for property composer. The value you gave, the specific string, is valid with an English version of InDesign and not with your Spanish version. The string "Adobe Paragraph Composer" will also not work with my German InDesign. Instead I have to use the string "Adobe-Absatzsetzer" if I want to address the composer in a localized way.

 

To make that independent of the localization of your InDesign use the independent strings.

Currently InDesign is able to use 6 different kinds of composers. Here is a list:

 

"$ID/HL Single J" > Adobe Japanese Single-line Composer
"$ID/HL Composer J" > Adobe Japanese Paragraph Composer

"$ID/HL Single" > Adobe Single-line Composer
"$ID/HL Composer" > Adobe Paragraph Composer

"$ID/HL Single Optyca" > Adobe World-Ready Single-line Composer
"$ID/HL Composer Optyca" > Adobe World-Ready Composer

 

That means: To make a script independent of the specific localization best use a string like "$ID/HL Composer" instead of "Adobe Paragraph Composer" when addressing property composer of a paragraph or a paragraph style.

 

And, as Manan already said, I would never try to change allParagraphStyles[0].

I would also add: Do not touch the [Basic Paragraph Style] as well, that is allParagraphStyles[1].

So if you loop through the allParagraphStyles array begin your loop with the third style:

for(var a=2;a<myDoc.allParagraphStyles.length;a++)

 

Regards,
Uwe Laubender

( ACP )

 

TOPICS
Scripting

Views

50

Likes

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

Mass Edit Paragraph Styles Options

Engaged ,
Nov 01, 2020

Copy link to clipboard

Copied

Hi, 

I have many paragraph styles, and I try to apply mass changes to all in the panel "Paragraph Styles Options", to change the language, maximun word spacing, etc...

 

Please can you see why my script doesn't work?

var myDoc = app.activeDocument;
ParaStyle_Reduce();
//alert("Process Completed...");

function ParaStyle_Reduce(){
	var countAllParagraphStyles = myDoc.allParagraphStyles.length;	//simple counter to indicate the progress on Javascript console
	$.writeln("countAllParagraphStyles: " + countAllParagraphStyles);
	for(var a=0;a<myDoc.allParagraphStyles.length;a++){	
		$.writeln("a: " + a);
		try{
			// MENU PARAGRAPH STYLE OPTION - Advance Character Formats
			myDoc.allParagraphStyles[a].horizontalScale = 100;
			myDoc.allParagraphStyles[a].verticalScale = 100;
			myDoc.allParagraphStyles[a].baselineShift = 0;
			myDoc.allParagraphStyles[a].skew = 0;
			myDoc.allParagraphStyles[a].appliedLanguage = "Spanish";
			

			// MENU PARAGRAPH STYLE OPTION - Justification
			myDoc.allParagraphStyles[a].minimumWordSpacing = 85;
			myDoc.allParagraphStyles[a].minimumLetterSpacing = -2;
			myDoc.allParagraphStyles[a].minimumGlyphScaling = 97;
			myDoc.allParagraphStyles[a].desiredWordSpacing = 100;
			myDoc.allParagraphStyles[a].desiredLetterSpacing = 0;
			myDoc.allParagraphStyles[a].desiredGlyphScaling = 100;
			myDoc.allParagraphStyles[a].maximumWordSpacing = 110;
			myDoc.allParagraphStyles[a].maximumLetterSpacing = 2;
			myDoc.allParagraphStyles[a].maximumGlyphScaling = 103;
			myDoc.allParagraphStyles[a].autoLeading = 120;
			myDoc.allParagraphStyles[a].singleWordJustification = SingleWordJustification.FULLY_JUSTIFIED;
			myDoc.allParagraphStyles[a].composer = "Adobe Paragraph Composer";

			// MENU PARAGRAPH STYLE OPTION - Justification
			// myDoc.allParagraphStyles[a].hyphenation = true;
			myDoc.allParagraphStyles[a].hyphenateWordsLongerThan = 5; 		// (range 3 - 25) also the name of this value is Words with at Least
			myDoc.allParagraphStyles[a].hyphenateAfterFirst	= 2;				
			myDoc.allParagraphStyles[a].hyphenateBeforeLast = 2;
			myDoc.allParagraphStyles[a].hyphenateLadderLimit = 2; 	// (range 0 - 25) also the name of this value is Hyphen Limit
			myDoc.allParagraphStyles[a].hyphenationZone = 0;
			myDoc.allParagraphStyles[a].hyphenWeight = 2;	// (range 0 - 10) also the name of this value is Better Spacing and Fewer Hyphens
			myDoc.allParagraphStyles[a].hyphenateCapitalizedWords = false;
			myDoc.allParagraphStyles[a].hyphenateLastWord = false;
			myDoc.allParagraphStyles[a].hyphenateAcrossColumns = false;

			$.writeln("Progress: " + a + " of " + countAllParagraphStyles + " Styles");  //simple counter to indicate the progress on Javascript console
		}catch(e){}
	}
}

 

thanks so much in advance!

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi Manuel,

the only property you are using that is not independent of the installed InDesign localized version is the value for property composer. The value you gave, the specific string, is valid with an English version of InDesign and not with your Spanish version. The string "Adobe Paragraph Composer" will also not work with my German InDesign. Instead I have to use the string "Adobe-Absatzsetzer" if I want to address the composer in a localized way.

 

To make that independent of the localization of your InDesign use the independent strings.

Currently InDesign is able to use 6 different kinds of composers. Here is a list:

 

"$ID/HL Single J" > Adobe Japanese Single-line Composer
"$ID/HL Composer J" > Adobe Japanese Paragraph Composer

"$ID/HL Single" > Adobe Single-line Composer
"$ID/HL Composer" > Adobe Paragraph Composer

"$ID/HL Single Optyca" > Adobe World-Ready Single-line Composer
"$ID/HL Composer Optyca" > Adobe World-Ready Composer

 

That means: To make a script independent of the specific localization best use a string like "$ID/HL Composer" instead of "Adobe Paragraph Composer" when addressing property composer of a paragraph or a paragraph style.

 

And, as Manan already said, I would never try to change allParagraphStyles[0].

I would also add: Do not touch the [Basic Paragraph Style] as well, that is allParagraphStyles[1].

So if you loop through the allParagraphStyles array begin your loop with the third style:

for(var a=2;a<myDoc.allParagraphStyles.length;a++)

 

Regards,
Uwe Laubender

( ACP )

 

TOPICS
Scripting

Views

51

Likes

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
Nov 01, 2020 0
Adobe Community Professional ,
Nov 01, 2020

Copy link to clipboard

Copied

It seems to be working for me. What specific problem do you spot? Also, a reminder, you are changing the Basic Paragraph Style as well with this code, that ain't advisable.

-Manan

Likes

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
Reply
Loading...
Nov 01, 2020 1
Engaged ,
Nov 01, 2020

Copy link to clipboard

Copied

Hi Manan,

Maybe is not related with the problem, but I unistall all my Adobe apps, and install again with English language (I had spanish versions), also I change my Operating System to english, and now works very good.

 

Thanks so much for check.

Likes

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
Reply
Loading...
Nov 01, 2020 0
Adobe Community Professional ,
Nov 02, 2020

Copy link to clipboard

Copied

Hi Manuel,

the only property you are using that is not independent of the installed InDesign localized version is the value for property composer. The value you gave, the specific string, is valid with an English version of InDesign and not with your Spanish version. The string "Adobe Paragraph Composer" will also not work with my German InDesign. Instead I have to use the string "Adobe-Absatzsetzer" if I want to address the composer in a localized way.

 

To make that independent of the localization of your InDesign use the independent strings.

Currently InDesign is able to use 6 different kinds of composers. Here is a list:

 

"$ID/HL Single J" > Adobe Japanese Single-line Composer
"$ID/HL Composer J" > Adobe Japanese Paragraph Composer

"$ID/HL Single" > Adobe Single-line Composer
"$ID/HL Composer" > Adobe Paragraph Composer

"$ID/HL Single Optyca" > Adobe World-Ready Single-line Composer
"$ID/HL Composer Optyca" > Adobe World-Ready Composer

 

That means: To make a script independent of the specific localization best use a string like "$ID/HL Composer" instead of "Adobe Paragraph Composer" when addressing property composer of a paragraph or a paragraph style.

 

And, as Manan already said, I would never try to change allParagraphStyles[0].

I would also add: Do not touch the [Basic Paragraph Style] as well, that is allParagraphStyles[1].

So if you loop through the allParagraphStyles array begin your loop with the third style:

for(var a=2;a<myDoc.allParagraphStyles.length;a++)

 

Regards,
Uwe Laubender

( ACP )

 

Likes

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
Reply
Loading...
Nov 02, 2020 2
Engaged ,
Nov 03, 2020

Copy link to clipboard

Copied

Hi Laubender,

thanks for your qualify answer, now I understand why didn't work.

here the final code:

 

var myDoc = app.activeDocument;
ParaStyle_Reduce();
//alert("Process Completed...");

function ParaStyle_Reduce(){
	var countAllParagraphStyles = myDoc.allParagraphStyles.length;	//simple counter to indicate the progress on Javascript console
	$.writeln("countAllParagraphStyles: " + countAllParagraphStyles);
	for(var a=2;a<myDoc.allParagraphStyles.length;a++){	
		$.writeln("a: " + a);
		try{
			// MENU PARAGRAPH STYLE OPTION - Advance Character Formats
			myDoc.allParagraphStyles[a].horizontalScale = 100;
			myDoc.allParagraphStyles[a].verticalScale = 100;
			myDoc.allParagraphStyles[a].baselineShift = 0;
			myDoc.allParagraphStyles[a].skew = 0;
			myDoc.allParagraphStyles[a].appliedLanguage = "Spanish";
			

			// MENU PARAGRAPH STYLE OPTION - Justification
			myDoc.allParagraphStyles[a].minimumWordSpacing = 85;
			myDoc.allParagraphStyles[a].minimumLetterSpacing = -2;
			myDoc.allParagraphStyles[a].minimumGlyphScaling = 97;
			myDoc.allParagraphStyles[a].desiredWordSpacing = 100;
			myDoc.allParagraphStyles[a].desiredLetterSpacing = 0;
			myDoc.allParagraphStyles[a].desiredGlyphScaling = 100;
			myDoc.allParagraphStyles[a].maximumWordSpacing = 110;
			myDoc.allParagraphStyles[a].maximumLetterSpacing = 2;
			myDoc.allParagraphStyles[a].maximumGlyphScaling = 103;
			myDoc.allParagraphStyles[a].autoLeading = 120;
			myDoc.allParagraphStyles[a].singleWordJustification = SingleWordJustification.FULLY_JUSTIFIED;
			myDoc.allParagraphStyles[a].composer = "$ID/HL Composer";

			// MENU PARAGRAPH STYLE OPTION - Justification
			// myDoc.allParagraphStyles[a].hyphenation = true;
			myDoc.allParagraphStyles[a].hyphenateWordsLongerThan = 5; 		// (range 3 - 25) also the name of this value is Words with at Least
			myDoc.allParagraphStyles[a].hyphenateAfterFirst	= 2;				
			myDoc.allParagraphStyles[a].hyphenateBeforeLast = 2;
			myDoc.allParagraphStyles[a].hyphenateLadderLimit = 2; 	// (range 0 - 25) also the name of this value is Hyphen Limit
			myDoc.allParagraphStyles[a].hyphenationZone = 0;
			myDoc.allParagraphStyles[a].hyphenWeight = 2;	// (range 0 - 10) also the name of this value is Better Spacing and Fewer Hyphens
			myDoc.allParagraphStyles[a].hyphenateCapitalizedWords = false;
			myDoc.allParagraphStyles[a].hyphenateLastWord = false;
			myDoc.allParagraphStyles[a].hyphenateAcrossColumns = false;

			$.writeln("Progress: " + a + " of " + countAllParagraphStyles + " Styles");  //simple counter to indicate the progress on Javascript console
		}catch(e){}
	}
}

 

 

Best regards 🙂

 

Likes

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
Reply
Loading...
Nov 03, 2020 0
Adobe Community Professional ,
Nov 03, 2020

Copy link to clipboard

Copied

Hi Manuel,

forgot one thing.

 

There is a second property in your code that uses a localization dependent value, and that is language .

 

Now to my procedure to get the international localization independent strings:

You could use method app.findKeyStrings() with your localized string to get an array of "international" strings.

 

In my German version of InDesign I could do this with:

app.findKeyStrings("Spanisch")

which returns the following array of strings:

// $ID/IDX_Spanish,$ID/Spanish,$ID/Spanish: Castilian

Why is the array's length larger than one item?

 

I assume that the German "Spanisch" is used at least with three different "meanings" or implementations all over the functions of the application or with the menus. The best bet here, if you want to pick a string for the value of language, would be perhaps "$ID/Spanish". Just try it. If it does not work, test one of the other two results.

 

Regards,
Uwe Laubender

( ACP )

 

Likes

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
Reply
Loading...
Nov 03, 2020 0