comet.book

The comet.book module provides functionality for managing InDesign® books

See also

Class CBook

CBook object instances represent actual InDesign® books

Methods

comet.book.create(path)

Create a new empty book.

The book is not opened automatically.

Parameters

path (str) –

Full path to the book file including extension.

Usually indb is used as extension for InDesign® books.

The path to the file is generated automatically if required.

Return type

None

Raises
Available

CScript

book::create

comet.book.open(path)

Open a book.

Parameters

path (str) – Full path to the existing book file

Returns

The opened book

Return type

CBook

Raises
Available

CScript

book::open

comet.book.getOpen()

Get all currently opened books.

Returns

All currently opened books

Return type

list[CBook]

Available

CScript
comet.book.getByPath(path)

Get an open book by the full path to the book file.

Parameters

path (str) – Full path to the book

Returns

The book which corresponds to the path

Return type

CBook

Raises
  • TypeError – When parameter types are invalid

  • ValueError – When parameter path is empty

  • KeyError – When no open book with the provided path exists

Available

CScript

book::get_by_path

comet.book.getCurrent()

Get the current active book.

Please note: The active book is the book you last worked on. The active book may change by script calls for other books!

Here is an article from InDesign Secrets:

A note on “activeBook”

One more note, in case you’re going to be scripting book panels: Before you add your own custom options to the Book panel, you have to make sure it works as intended in a standalone script. Now there is something weird going on when using ‘activeBook’. Other than, say, ‘activeDocument’, ‘activeBook’ does not always get right what book document is the active one! The reason for this is that you can have several book panels open at a time, scattered about your workspace. Which one is then “active”? So when experimenting with this, you’d better make sure you only have one single book open. I was kind of weary of this issue when testing my open/close script, but it seems that if you call a script from within the book panel itself, ‘the’ active book is indeed the one you called the menu from, so the problem resolved itself.

Returns

The currently active book, or None if none is active

Return type

CBook | None

Available

See also

CBook.setCurrent()

CScript

book::get_current