Skip to main content
Inspiring
September 6, 2012
Question

ID-Server CS6(win/mac): getting front document in indesign server?

  • September 6, 2012
  • 1 reply
  • 1385 views

hi all,

I made a scriptable plugin( KModelPlugin ) which needs to access the front document.

I used Utils<ILayoutUIUtils>()->GetFrontDocument(); but later I read that this does not work on indesign server.

I have never worked with indesign server and don't know how it works. But I want my plugin to work on it. So, is there a way to ensure my plugin runs on indesign server too?

[i.e getting the front document. I wonder how app.activedocument() is implemented.]

thanks and regards

maddy1907

This topic has been closed for replies.

1 reply

Community Expert
September 6, 2012

You can try using the IDocumentList interface to get the current active document. The method "GetNthDoc" of this interface should work for you. I suppose the document at index 0 is the active document, you can easily figure it out though.

Manan Joshi

- Efficient InDesign Solutions

-MetaDesign Solutions

http://metadesignsolutions.com/services/indesign-development.php

-Manan
maddy1907Author
Inspiring
September 7, 2012

Manan Joshi wrote:

You can try using the IDocumentList interface to get the current active document. The method "GetNthDoc" of this interface should work for you. I suppose the document at index 0 is the active document, you can easily figure it out though.

Manan Joshi

- Efficient InDesign Solutions

-MetaDesign Solutions

http://metadesignsolutions.com/services/indesign-development.php

Hi,

Thanks for your prompt reply. I already did try this interface before but it only returns the documents placed at index 0 in the document display tab. in the order in which they were opened.

This was my code:

InterfacePtr<IApplication>application(GetExecutionContextSession()->QueryApplication());

InterfacePtr<IDocumentList> documentList(application->QueryDocumentList());

int32 docCount = documentList->GetDocCount();

          if(docCount>0)

for(int32 i=0;i<docCount;i++)

          {         

                    IDocument* document = documentList->GetNthDoc(i);

                    IDocument* document = documentList->GetNthDoc(i);

                    if(document!=nil)

                            {

                                    PMString name;

                                    document->GetName(name);

                                    CAlert::InformationAlert(name);

                            }

          }

Did I miss something?

Thanks and Regards

maddy1907


Community Expert
September 7, 2012

You are right, the GetNthDoc API indeed gives the documents in the order in which they were opened(my bad!!).

So in that case i don't think that there is a direct API that will solve your purpose. You will have to store the instance of the documents when you create them and switch between them, to keep a tab of the current document.

Also even if you have any reference to some object on the current document you can get it's IDocument interface by, using the

IDataBase::GetRootUID which will give the UID of the document.

Since i am not aware of the exact situation of your code at the time when you try to retireve this IDocument interface and the code's structure as a whole so cannot point you to the exact solution. But these pointers in itself should be sufficient to help you come up with a solution.

Thanks

-Manan

.

-Manan