Last active
November 18, 2015 10:25
-
-
Save milligramme/f9a70e952903db8b0ad3 to your computer and use it in GitHub Desktop.
update toc in indesign document
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #target "InDesign" | |
| var update_toc = function (doc, opt) { | |
| var story_len = doc.stories.length; | |
| var _story, _toc_tfs; | |
| var toc_styles = doc.tocStyles; | |
| for (var i=0, len=toc_styles.length; i < len ; i++) { | |
| _story = doc.createTOC(toc_styles[i], true); | |
| if (opt.only_used && doc.stories.length > story_len ) { | |
| _toc_tfs = _story[0].textContainers; | |
| for (var j = _toc_tfs.length - 1; j >= 0; j--) { | |
| // remove textfreame created by unused toc-style | |
| _toc_tfs[j].remove(); | |
| } | |
| } | |
| }; | |
| }; | |
| var doc = app.documents[0]; | |
| update_toc(doc, {only_used: true}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment