CHAPTER 1: Layout Documents 9
To iterate through documents, use IDocumentList to list the documents that are open in the application.
See “Iterating through documents”.
If you have an IDataBase pointer, call IDataBase::GetRootUID. The document associated with a database (if
any) can be discovered using code like the following:
InterfacePtr<IDocument> document(db, db->GetRootUID(), UseDefaultIID());
if (document != nil) // use the document interface
If you have a UIDRef:
1. Call UIDRef::GetDataBase to discover the IDataBase pointer.
2. Use the pointer to acquire the document as described above.
If you have an interface pointer for any interface on a UID-based object (for example, an IHierarchy
interface):
1. Call the PersistUtils function ::GetDataBase to discover the IDataBase pointer.
2. Use the pointer to acquire the document as described above.
If you have an IActiveContext interface, call IActiveContext::GetContextDocument. The document
associated with this context (if any) can be found using code like the following:
IDocument* document = activeContext->GetContextDocument();
if (document != nil) // use the document interface
If you have a layout view, call ILayoutControlData::GetDocument. For details, in the “Layout Fundamentals”
chapter of Adobe InDesign Programming Guide, see “The Layout Window and View” section. This call often
is used by trackers (ITracker).
To work with the document the user is editing, call ILayoutUIUtils::GetFrontDocument.
Related API
IDocument
Creating a document
Creating a document with a setup of your own choice
You can create a document and specify the number of pages, page size, and so on that the new document
should have.
Solution
1. To create the command, call IDocumentCommands::CreateNewCommand.
2. Populate the command’s INewDocCmdData data interface to describe the desired set-up.
3. Process the command.
Sample Code
SDKLayoutHelper::CreateDocument