I'm working on a script that attempts to review all page references on each topic of an index in order to remove duplicates and build page ranges...
So far I get the referenceType for each pageReference, but it only returns the 'referenceType' and not the current page as the Indesign 8 Object Model says:
PageReferenceType.CURRENT_PAGE (Read Only)
Data Type: number , Value: 1668444263
Adobe InDesign CS6 (8.0) Object Model
The page on which the index entry is located.
The followin script write in console each topic's name and its references (as 1668444263 if is of type CURRENT_PAGE), and I would like to get the real current page number...
Any help really appreciated!!
var index = app.documents.indexes;
for (i = 0; i < index.topics.length ; i++)
$.write("Topic: " + index.topics[i].name + "\n");
for (t = 0; t < index.topics[i].pageReferences.length ; t++)
var pRef = index.topics[i].pageReferences[t].pageReferenceType;
$.write(pRef + "\n");
The type tells you what type of index entry page number it is :)
Try .sourceText -- http://jongware.mit.edu/idcs6js/pc_PageReference.html#sourceText -- this points to the insertionPoint in the actual text, the location of the index entry itself. From that you can use its parentTextframe and next that one's parentPage to get the page number (which should be the "name" of the page).
You are welcome. I'm curious -- does your script generate a different index than ID's own?
(I suppose this function could benefit from the odd enhancement here and there ... but usually that's done by cleaning up the generated index, for example with Peter Kahrel's Index Fixing script at http://www.kahrel.plus.com/indesign/index_update.html)
Well... The script I'm trying to build kinda do the same of Kahrel's but in ID's own index, not the one generated. Mostly because I'm editing the index constantly for revision and at the same time editing the body text and it feels creepy to 'clean' those entries in that generated script and keep ID's index 'dirty'.
The really weird thing I'm facing right now is that ID's 'book' option is not clear enough, and so far I've found that every document in a book has it's own index and somehow ID shares its topics and entries so that you can view the total index while working in any document of the book [although it takes its time to refresh…]. In a scripting point of view... you cannot get all entries across all book's documents, and that make entries processing a tough job... scriptingly speaking...
For now I'm trying to assign key-labels so that the topics and their entries are easily retrieved and processed avoiding as many loops as possible…
If u've found of know about any other way for working with indexes on books, please share and spare my head hitting the wall at nights…
> .. If u've found of know about any other way for working with indexes on books, please share and spare my head hitting the wall at nights…
Quite the contrary :) Much as I like ID, its indexing features are just not good enough for Real World Indexes. Fortunately I don't have to create, correct, and maintain indexes. When asked to, I copy the ID text page by page to a Word document, let its concordance feature create a rough index for me, and send this back to the publisher for its editors to manually enhance/edit/adjust/amend.
Europe, Middle East and Africa