TOC Creation request

Explorer ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

HI,

I have trouble to enable the "includeBookDocuments" and "removeForcedLineBreak", my code is here, but the resule was enabled "bookmarks" and "replace toc".

 

I need to enable "includeBookDocuments" and "removeForcedLineBreak" only.

 

kindly chec my code and correct me..

 

var tocStyles = ["style1","Style2","Style3"];


var doc = app.activeDocument;
var tocNewStyle = doc.paragraphStyles.add({name:"tempTOC", appliedFont:"Arial", fontStyle: "Regular", pointSize:2});

var myTOC = app.activeDocument.tocStyles.add();
myTOC.name = "MyTOCStyle";
myTOC.title = "Contents";
myTOC.titleStyle = app.activeDocument.paragraphStyles[3]; // enter the paragraph style to apply to the TOC title.
myTOC.includeBookDocuments = true;
myTOC.removeForcedLineBreak = true;

for(i=0; i<tocStyles.length; i++)
{
style = app.activeDocument.paragraphStyles.item(tocStyles[i]); // enter the paragraph style for "include paragraph styles"
myTOC.tocStyleEntries.add({formatStyle:tocNewStyle, name:style.name, separator:"\t"});
}
app.activeDocument.createTOC(myTOC);

 

rikanth_0-1654580219534.png

 

TOPICS
Scripting

Views

62

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
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Jun 07, 2022 Jun 07, 2022
You need to tell createTOC() which book and which TOC style to use: app.activeDocument.createTOC (myTOC, true, myBook);

Likes

Translate

Translate
Adobe Community Professional ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

The options that you highlighted don't work when you generate the TOC with a script. It's a known bug.

P.

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
community guidelines
Explorer ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

Hi Peter,

Is there any way to prodecue the TOC.

 

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
community guidelines
Adobe Community Professional ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

LATEST

You need to tell createTOC() which book and which TOC style to use:

app.activeDocument.createTOC (myTOC, true, myBook);

 

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
community guidelines