Initializing and terminating a session

HOOPS Publish uses two different libraries that need to be initialized separately: the A3DLIBS library shares the code for the whole HOOPS Publish and HOOPS Exchange APIs while the PDF library is used internally to implement PDF functionnalities.

Loading the A3DLIBS library and accessing functions

A3DLIBS uses explicit linking to access the functions in the API. With explicit linking, the executable using the DLL must make function calls to explicitly load and unload the DLL, and to access the DLL-exported functions through a function pointer. HOOPS Publish is delivered with a unique top-level header file A3DSDKIncludes.h to help access the API. This is the only header that needs to be included in your application. Depending on the level of the product license purchased, certain macros must be defined before including this header:

This top-level header defines two functions to initialize and terminate a session with the A3DLIBS DLL, as well as a macro that automates the definitions of function pointers for the whole API:

In your main code segment, define INITIALIZE_A3D_API before including A3DSDKIncludes.h, then a call to A3DSDKLoadLibrary will automatically load the DLL (A3DLIBS.DLL) and call GetProcAddress on each function. At the end of your program, call A3DSDKUnloadLibrary to unload this library.

#include "A3DSDKIncludes.h"
if (!A3DSDKLoadLibrary(_T("")))
printf("Cannot load library\n");

Initializing the A3DLIBS DLL

A3DInt32 iMajorVersion = 0, iMinorVersion = 0;
A3DInt32 iRet;
iRet = A3DDllGetVersion(&iMajorVersion, &iMinorVersion);
if(iRet == A3D_SUCCESS) { ... };
if(iRet == A3D_SUCCESS) { ... };

Initializing the PDF library and resources

HOOPS Publish uses the Adobe native PDF library. This library must be initialized.

In addition, the directory where specific resources for font management are defined must be initialized. This is all done using the A3DPDFInitializePDFLibAndResourceDirectory function:

if(iRet == A3D_SUCCESS) { ... };

When installing HOOPS Publish, the resource directory is provided in the bin directory.

Terminating the PDF library and A3DLibs DLL

Terminate the PDF library by invoking the A3DPDFTerminatePDFLib function:

Then, terminate HOOPS Publish by calling:

iRet = A3DDllTerminate();

This last step should not be performed if you've used automatic initialization with the HOOPS Exchange Loader.

Handling errors

Most of the HOOPS Publish API functions return an integer that indicates success or failure. A return value of A3D_SUCCESS indicates success, and any negative return value indicates failure. The following example shows one approach for evaluating this returned result:

iRet = A3DPDFDocumentCreateFromPDFFile(in_pdftemplatefile, &pDoc);
if(iRet == A3D_SUCCESS) { ... };

Error codes are detailed in the A3DSDKErrorCodes.h file.

top_level:1 prog_guide:0