Copy link to clipboard
Copied
Hello,
Is there a simple way to find out if a document is part of a InDesign book and to check if this book is also opened? I didn't find anything in the documentation.
I know that I can check the list of open books and look if the document is part of one of this books. But I hope there is a kind of isInBook() function that I didn't found.
Thanks for any tipps
Klaus
Copy link to clipboard
Copied
Hi Klaus,
no. I don't think so, there is no simpler way.
You possibly could write a parser that could filter out the paths and names of InDesign documents that are in a closed book file.
I inspected a book file with my text editor and the paths could be identified in readable form with their platform specific encoding.
Regards,
Uwe
Copy link to clipboard
Copied
tell application id "com.adobe.indesign"
-- exists (book contents of every book whose full name is full name of active document)
full name of active document is in (full name of every book content of every book)
end tell
If the search should only consider the opened books, the commented out line would be the fastest (in execution time) solution. Unfortunately Adobe never supported the full power of AppleScript, where you could push that kind of expressions into the scripted application. The line below works by building a list and performing the search in the AppleScript runtime.
Translating that to ExtendScript requires a shim for Array.indexOf ...
("…"+app.books.everyItem().bookContents.everyItem().fullName.join("…")+"…").indexOf("…"+app.activeDocument.fullName+"…")>=0
Btw, I would not rely on those strings from book contents without thorough testing - books can get moved in the FS. Some of the properties used to be redundant and/or only partially maintained when a book recovered from such a move, I never checked whether that was cleaned up internally in the file format when the bug was fixed ages ago.
Dirk
Copy link to clipboard
Copied
Thanks - writing my own function to test this is not the problem - I'm just wondering that there was no build in function for that.