Monday, April 9, 2012

Develop Acrobat Plug-ins

Plug-ins
Plug-ins are dynamically-linked extensions to Acrobat or Adobe Reader. They can hook in to the user interface in a number of ways and can register to be called when a variety of events occur in the application.
A plug-in is written in ANSI C/C++ and uses the Acrobat public APIs. It can add functionality to Acrobat Pro Extended, Acrobat Professional, Acrobat Standard, or Adobe Reader. A plug-in program file goes into a Plug_ins folder or directory and is initialized during Acrobat or Adobe Reader startup.
There are three types of plug-ins:
  • Regular Acrobat plug-ins—These plug-ins run on Acrobat Professional and Acrobat Standard. Plug-ins for Acrobat Professional can use any of the Acrobat SDK APIs. Plug-ins for Acrobat Standard do not have access to some APIs.
  • Adobe Reader-enabled plug-ins—These plug-ins use a restricted set of APIs. Adobe Reader-enabled plug-ins are developed with permission from Adobe and require special processing to load under Adobe Reader. Plug-ins for Adobe Reader can use additional APIs if the PDF document has additional usage rights.
  • Certified plug-ins—These plug-ins have undergone extensive testing to ensure that they do not compromise the integrity of Acrobat's security model. A checkbox in the Acrobat and Adobe Reader user interface can be used to ensure that only certified plug-ins are loaded. Certified plug-ins can be provided only by Adobe.
On Windows, plug-ins are DLLs. However, plug-in names must end in .API, not .DLL. On Mac OS, plug-ins are code fragments, whereas on UNIX, plug-ins are shared libraries.


How to develop plugin:

When developing plugins using AFC Library the user has to derive his own plug in application class from the AFC core class AfcPIApp. And subsequently he/she has to override the member functionsSetPluginName , PluginInitialize , PluginImportReplaceAndRegister , PluginExportHFTs and PluginUnload. 


The SetPluginName function needs to be overridden by the user and should be implemented thus, so that the  function returns a pointer to a character string which is a unique name associated with the plug-in.

The PluginInitialize function is called by the Acrobat viewer during initialization to allow a plug-in to do any sort of initialization it requires, such as adding user interface. If the function returns false, thePluginUnload member function is called.

The PluginUnload function is called by the Acrobat viewer when the plug-in unloads to allow it to perform any sort of cleanup needed. Use this member function to release any system resources you may have allocated.
The PluginExportHFTs member function is called by the Acrobat viewer during initialization to allow a plug-in to export one or more HFTs to other plug-ins. Inside this member function the user should not do anything other than export HFTs. Plug-ins should not change the user interface at this time, do that in the PluginInitialize member function.

The PluginImportReplaceAndRegister member function is called by the viewer during the initialization to allow a plug-in to import HFT to another plug-in or replace an HFT method. This is the only place that a plug-in may replace a HFT method. Plug-ins should not change the user interface at this time, do that in the PluginInitialize member function.

// MyApp construction
MyApp ::MyApp ()
{
      // add construction code here,
      // Place all significant initialization in PluginInitialize 
}

// The one and only MyApp object
MyApp thePIApp;

// MyApp registering unique name
char* MyApp ::SetPluginName()
{
      char* m_szName;
      ......................
      ......................
      return m_szName;
}
// MyApp initialization
bool MyApp ::PluginInitialize()
{
       // intialization code goes here
          .......................
          .......................
          .......................
               return true;
          .......................
          .......................
          .......................
               return false;
}
// Import HFT to another plug-in or replace an HFT method.
bool MyApp ::PluginImportReplaceAndRegister()
{
          .......................
          .......................
          .......................
               return true;
          .......................
          .......................
          .......................
              return false;
}
// Export one or more HFTs to other plug-ins
bool MyApp ::PluginExportHFTs()
{
          .......................
          .......................
          .......................
              return true;
          .......................
          .......................
          .......................
             return false;
}
// MyApp,plug-in unloads
bool MyApp ::PluginUnload()
{
          .......................
          .......................
          .......................
              return true;
          .......................
          .......................
          .......................
              return false;
}

// MyApp destructor
MyApp ::~MyApp ()
{
      // add destruction code here,
      // Place all significant resource clean ups
}

No comments:

Post a Comment