Copy link to clipboard
Copied
I use Extendscript to help me review students' work in InDesign. I run a script (.jsx) that goes through a document and creates a report. The point is to avoid manual, tedious and error-prone work for about 5 InDesign files x 60 students per semester. The report already includes many things like page size, bleed, margins, parent page columns and application, text style options, baseline grid, etc. This script saves me a HUGE amount of time and makes it less likely that I'll forget to check for anything in particular.
What I cannot do yet is to include in this report wether or nor unused paragraph and character styles exist, preferably listing their names.
I tried:
Searching the documentation for a property that might indicate if the paragraph/character style is being used or not.
Invoking (.invoke() method) the Select All Unused menu action from the Paragraph Styles panel. I explored adding event listeners and looking for any results, and also checked the Panel javascript documentation for any way to access a selection. According to what little I found, this is not possible because there's nothing relative to a selection regarding UI elements.
I also considered looping through all stories and paragraphs, checking for the styles in use, and accounting for styles used inside other styles (like "based on"). I've yet to explore scripting with find/replace, because that option would not tell me wether a style with zero uses is the basis for another style. Also, I feel there should be a simpler alternative. Does anyone know of one?
Copy link to clipboard
Copied
@Robert at ID-Tasker – Yes, and yes.
We're looking for used styles (so that the unused ones remain) and I provided a list of candidates where we can ignore the methods.
Copy link to clipboard
Copied
?? Then what is wrong with my idea?
Copy link to clipboard
Copied
Robert, your idea is great—nothing wrong with it as far as I can tell. When I have time I'm going to try it and Peter's idea and look into how difficult it would be to adapt my initial approach to collect all the little edge cases that Dirk mentions. I think Manan will be really interested too. I'm pretty sure that your idea and Peter's will be the easiest to implement. Anyhow, it'll be fun to explore. Just too busy right now...
- Mark
Copy link to clipboard
Copied
Yes, my and Peter's are almost exactly the same 😉
I just don't understand what is the point of going through all the possible locations in the *Styles to check if style is used?
Unless the goal changed?
Copy link to clipboard
Copied
All you are saying about style's dependencies is rather obvious 😉
That's why I've suggested copying pages to a new document - all this headache will be InDesign's problem 😉 scripter will have to just compare the lists 😉
And checking if right style have been used - first, you have to check WHERE it has been used, not just IF.
About your last part - and re-importing styles - it should be done through template - not by importing file from last month 😞
Copy link to clipboard
Copied
> That's why I've suggested copying pages to a new document
Robert's idea of copying all text to a second document is clever, but there's no need to copy pages. All you need to do is duplicate all the document's page items to a new document and that document will then contain only the used styles:
app.documents[0].pageItems.everyItem().duplicate (
app.documents[1].pages[0]
);
Everything will be on the first page on top of each other, but that doesn't matter. Then you can compare the two documents and obtain the unused styles.
Naturally, all the caveats that Dirk mentioned still apply.
P.
Copy link to clipboard
Copied
Yeah 😉 but would be great to check on some large / complicated document if copying whole pages wouldn't be quicker 😉
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more