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

Need to change predefined paragraph style items in multiple Indesign files with javascript ....

Community Beginner ,
Dec 04, 2019 Dec 04, 2019

Hi,
I need to change a predefined paragraph style in 50 to 75 Indesign files. The paragraph style name is called “3. text”.  Can someone help me wirte a simple javascript line to change the applied font name “Times New Roman” and fontstyle “Regular” to font name “YaleNew” and fontstyle “Roman”?

Thanks in advance for your assistance.
-Greg

TOPICS
How to , Scripting , Type
1.8K
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

Contributor , Dec 04, 2019 Dec 04, 2019

Hi,

if a one liner is simply enough than this should do the trick

app.activeDocument.paragraphStyles.itemByName("3. text").appliedFont = "YaleNew\tRoman";

It will only change the font of the paragraph style 3. text in the currently active document.

Translate
Contributor ,
Dec 04, 2019 Dec 04, 2019

Hi,

if a one liner is simply enough than this should do the trick

app.activeDocument.paragraphStyles.itemByName("3. text").appliedFont = "YaleNew\tRoman";

It will only change the font of the paragraph style 3. text in the currently active document.

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 ,
Dec 04, 2019 Dec 04, 2019

Thanks Crazy Panda for your response and YES it does exactly what I need! 

Now to make this script complete, can you give me another javascript one liner that will change the capitalization to Open Type Small Caps for character style called "3b. text, cap" ?

I attempted the following with no success:

app.activeDocument.characterStyles.itemByName("3b. text, cap").appliedFont = "YaleNew\tRoman", Capitalization.CAP_TO_SMALL_CAP;



-Greg

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 ,
Dec 04, 2019 Dec 04, 2019

For capitalization you need to set the capitalization property as follows

 

app.activeDocument.characterStyles.itemByName("3b. text, cap").capitalization = Capitalization.CAP_TO_SMALL_CAP

 

 

For a complete list of properties and methods for character styles you can check the following link

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#CharacterStyle.html

 

-Manan

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
Contributor ,
Dec 04, 2019 Dec 04, 2019

if you want to change both the font and the capitalization with one line:

app.activeDocument.characterStyles.itemByName("3b. text, cap").properties = {appliedFont: "YaleNew\tRoman", capitalization: Capitalization.CAP_TO_SMALL_CAP};

 

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 ,
Dec 05, 2019 Dec 05, 2019

Exactly what I needed, thanks! I also appreciate the "CharacterStyle ExtendScriptAPL" link, however, I'm having difficult with some of the syntax.

For example, I tried to include OpenTypeFigureStyle.PROPORTIONAL_OLDSTYLE as follows:

app.activeDocument.paragraphStyles.itemByName("3. text").appliedFont= "YaleNew\tRoman", .otfFigureStyle.PROPORTIONAL_OLDSTYLE;


But this does not work. Can you help explain what I'm doing incorrectly?

-Greg

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 ,
Dec 06, 2019 Dec 06, 2019
LATEST

Ok, all resoloved after much trial and error. 😞
I was able to get the "PROPORTIONAL_OLDSTYLE" syntax to work using the following code:

app.activeDocument.paragraphStyles.itemByName("3. text").properties = {appliedFont: "YaleNew\tRoman", otfFigureStyle: OTFFigureStyle.PROPORTIONAL_OLDSTYLE};

Thanks again for all the assistance. 😉

-Greg

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