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

Change ToC font size and line spacing using Javascript

Community Beginner ,
Sep 09, 2024 Sep 09, 2024

I'm using InDesign CS5.5 and the ExtendScript Toolkit 4.1.28

I want to change the color, size and line spacing of a ToC after the update

 

I used 

var toc = ... // my Story
toc.textContainers[0].select()
app.menuActions.item("$ID/UpdateTableOfContentsCmd").invoke();

toc.texts[0].fillColor = "Black"; // it Works

toc.texts[0].appliedParagraphStyle.pointSize = 7; // applied only to the first row
var parStyle = toc.texts[0].appliedParagraphStyle;
parStyle.pointSize = 7;
toc.texts[0].applyParagraphStyle(parStyle); // Applied to all, but the entire style including underline and so on, not only the font size

var paragraphs = toc.paragraphs
for (var i = 0 ; i < paragraphs.length; i++ ) {
     paragraphs[i].appliedParagraphStyle.pointSize = 7; // not working
     }

 

How can I set the font size and the line spacint to the entire object? (title + ToC)

 

Manually i enter in the textBox, I click Ctrl+A (Select ALL) and I use the two forms as shown

social_Dream98A2_0-1725891637547.pngexpand image

 

Thanks

TOPICS
Scripting
177
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 , Sep 09, 2024 Sep 09, 2024

Hi @giovanni_4827 ,

use properties of the story:

// Variable toc is holding a story object:
toc.pointSize = 7;
toc.leading = Leading.AUTO;
toc.fillColor = "Black";

 See: https://www.indesignjs.de/extendscriptAPI/indesign8/#Story.html

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Translate
Community Expert ,
Sep 09, 2024 Sep 09, 2024
LATEST

Hi @giovanni_4827 ,

use properties of the story:

// Variable toc is holding a story object:
toc.pointSize = 7;
toc.leading = Leading.AUTO;
toc.fillColor = "Black";

 See: https://www.indesignjs.de/extendscriptAPI/indesign8/#Story.html

 

Regards,
Uwe Laubender
( Adobe Community Expert )

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