Skip to main content
August 3, 2009
Question

int main() where is it?

  • August 3, 2009
  • 2 replies
  • 1609 views

Hi all

I'm new to indesign sdk. I'm confused with sdk & c++. actually where from the code starts?

thanks

THAMIL

This topic has been closed for replies.

2 replies

Participating Frequently
August 4, 2009

If you are looking for an entry point, check out - class PlugIn : public IPlugIn

There is a default implementation that all samples use, /source/sdksamples/common/SDKPlugInEntrypoint.cpp

Good luck

-Jack

August 4, 2009

thank u both

And how can I close a document?

THAMIL

Inspiring
August 4, 2009

The best way to close a document is via its IDocFileHandler:

UIDRef docRef = GetUIDRef(...your IDocument...);

InterfacePtr<IDocFileHandler> docFileHandler(Utils<IDocumentUtils>()->QueryDocFileHandler(docRef));

if (docFileHandler)

{

     if (docFileHandler->CanClose(docRef))

     {

          docFileHandler->Close(docRef, K2::kSuppressUI, kFalse /* no cancel */, IDocFileHandler::kProcess);

          err = ErrorUtils::PMGetGlobalErrorCode();

          // check error

     }

}

Good luck.

Jon

Inspiring
August 3, 2009

There is no main() for InDesign plug-ins.  InDesign starts up and calls your plug-in as needed by the classes you create as part of your plug-in.  By creating objects which implement InDesign interfaces you get called when InDesign uses those interfaces.  If you create classes for a palette, for example, you'll get called when InDesign builds all the palettes and again when the users clicks in yours.

It's a bit daunting in the beginning because there are so many interfaces available to implement and you don't have a good idea how InDesign uses them. That's where the documentation comes in.  Read the files learning-indesign-plugin-development.pdf and programming-guide.pdf which are in the SDK under docs/guides.

Jon