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);
You need to tell createTOC() which book and which TOC style to use:
app.activeDocument.createTOC (myTOC, true, myBook);
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.
Copy link to clipboard
Copied
Hi Peter,
Is there any way to prodecue the TOC.
Copy link to clipboard
Copied
You need to tell createTOC() which book and which TOC style to use:
app.activeDocument.createTOC (myTOC, true, myBook);