Copy link to clipboard
Copied
Hi friends,
i am new to indesign javascript. i want to create a javascript for TOC indesign book using paragrph style
could anyone help me. i am strugling long time.
Copy link to clipboard
Copied
That sounds like the regular TOC function (it also works on Books).
Do you want to have a script that does the same without using the built-in TOC function (which is ... well, not really necessary, is it?), or do you want to use the TOC function through Javascript? (See in the ESTK Help: TOCStyle, TOCStyleEntry for the definitions, and Document.createTOC to actually create it.)
Copy link to clipboard
Copied
Thank you very much Jongware for your reply. Actualy i tried predefined function createTOC(). but it did'nt wotk for me.
i want to do in without buildin function .
Copy link to clipboard
Copied
Maybe IndexMatic could help you in this task.
You can download the script from this page:
http://www.indiscripts.com/post/2009/10/indiscripts-temporary-archives
@+
Marc
Copy link to clipboard
Copied
"It didn't work for me" doesn't work for me. Always, always, always, state why it doesn't work for you.
Did you try to use it, but could not get it to work?
Or, do you need to do something special that the built-in function does not do?
It should not be extremely hard to make a javascript version that does (roughly) the same. You could try something like this:
The IndexMatic script that Marc points out should already contains lots of the logic described here -- esp. searching and storing page numbers.
[Ed.] Thinking about it, a Book (multiple documents) should *not* cause any problems, and you don't need to know in which document some text was found. Simply sort the paragraphs on their page number; only when these are the same for more than one paragraph, sort just these on their Story Offset. Logically, there should not be two headers with the same page number in two different documents.
Copy link to clipboard
Copied
Hi Jongware,
with your valuable help i created TOC using predefined function. i defined the TOC style created from Layout---->Table of contenet--->TOCStyle.
but i want to create through script. can u tell me the syntax.
Copy link to clipboard
Copied
The syntax is
Array of Story createTOC (using: TOCStyle[, replacing: bool=false][, fromBook: Book][, placePoint: Array of Measurement Unit (Number or String)=any][, includeOverset: bool=false][, destinationLayer: Layer])
Creates a table of contents.
Parameter | Type | Description |
---|---|---|
using | TOCStyle | The TOC style to use to define the content, title, and format of the table of contents. |
replacing | bool | If true, replaces the existing TOC. (Optional) (default: false) (Optional) |
fromBook | Book | The book whose documents to include in the TOC. (Optional) |
placePoint | Array of Measurement Unit (Number or String)=any | The point at which to place the TOC story, specified as page coordinates in the format [x, y]. (Optional) |
includeOverset | bool | If true, includes overset text TOC entries in the TOC. (Optional) (default: false) (Optional) |
destinationLayer | Layer | The layer on which to place the TOC. (Optional) |
-- and I copied it from the ESTK Help, which is, really, the best place to look up the syntax for any JS command ...
Copy link to clipboard
Copied
I am wondering if you need a script. The TOC feature in InDesign CS4 seems pretty easy to use. I think it takes a bit of understanding how the TOC feature works.
I'm relatively new using ID CS4, however I use the built-in feasture all the time. Let me know if you use the TOC feature (in the Layou menu).
RPP
Copy link to clipboard
Copied
can you tell me how to use. i tried buildin createTOC(). i am getting confused with parameter. it's worked for me . but TOC placed when i go to Layout-->
table of contents and if i click the TOC style-->paragraph style. The TOC place into the 4th page. why it's not working in this code i don't know.
here i place the code.
function toc() {
// Set MyTOCStyle = myDoc.TOCStyles.Add
//Set myPage = myDocument.Pages.Item(1)
var myTOCStyle = myDocument.tocStyles.itemByName("TOC");
var myTocPage = myDocument.pages.add(LocationOptions.AT_END);
var myBounds = myGetBounds(myDocument, myTocPage);
var myX1 = myBounds[1];
var myY1 = myBounds[0];
var myStory = myDocument.createTOC(myTOCStyle, true, undefined, [myX1, myY1]);
var myFrame = myStory.textContainers[0];
}
toc();