
Adobe Acrobat SDK
Creating Plug-in and PDF Library Applications
Developing Plug-ins and Applications
Mac OS techniques 46
In all cases, you should pass
GetMainDevice
unless you have a particular device in mind or you are
restoring the GWorld to its original state. The following code is an example.
ACCB void ACCB2 foo(AVPageView pageView)
{
CGrafPtr oldGWorld, pagePort = NULL;
GDHandle oldDevice;
pagePort = (CGrafPtr)AVPageViewAcquireMachinePort(pageView);
if (pagePort){
GetGWorld(&oldGWorld, &oldDevice);
SetGWorld(pagePort, GetMainDevice());
//Draw to the port here
SetGWorld(oldGWorld, oldDevice);
AVPageViewReleaseMachinePort(pageView, pagePort);
}
}
Locating and loading plug-ins\
When Acrobat or Adobe Reader launches, it scans the plug-ins folder to locate and load plug-ins with the
acroplugin file extension. PowerPC plug-ins must have creator
CARO
(CFBundleSignature) and type
XTND
(CFBundlePackageType). Each plug-in exports a single main entry point,
AcroPluginMain
. When
loading a plug-in, Acrobat or Adobe Reader jumps to the plug-in’s entry point to begin handshaking. For
information, see
“Handshaking and Initialization” on page 28
.
Using memory
The Acrobat or Adobe Reader memory allocator gets its memory from the system and not from the
application's memory partition. For information, see
“Acquiring and releasing objects” on page 35
.
Memory allocation guidelines are particularly important in Mac OS to insure that memory is allocated from
the system rather than from the application partition. Otherwise your plug-in is very likely to cause
Acrobat or Adobe Reader to run out of memory.
Resource file considerations
Acrobat or Adobe Reader open a plug-in’s resource file with read-only permissions. In addition, plug-ins
cannot assume that their resource file is on top of the resource chain each time they are entered via an
ASCallback
. Plug-ins must explicitly move their resource file to the top of the resource chain before
accessing resources in it. As a result, all code that directly or indirectly invokes
GetResource
must be
modified. This can be accomplished either directly or by using the SafeResources routines in the Acrobat
SDK.
Using SafeResources
The recommended way to access resources in the plug-in file is to use the functions declared in the header
file SafeResources.h in the SDK. These functions are direct replacements for each Toolbox function that
directly or indirectly calls
GetResource
. The replacement functions automatically place the plug-in file
on top of the resource chain before accessing the resource, and restore the old resource chain after
accessing the resource.