DynaPDF Manual - Page 44

Previous Page 43   Index   Next Page 45

Language Bindings
Page 44 of 839
Embarcadero Delphi
The usage of DynaPDF with Embarcadero's Delphi is essentially the same as with C or C++
except that the exported DLL functions are encapsulated in the wrapper class TPDF to make the
usage easier. The instance pointer IPDF that is used by every DynaPDF function is hidden for
the user in Delphi. The instance pointer is controlled by the wrapper class so that you don't
need to create PDF instances manually.
To use DynaPDF with Delphi, proceed as follows:
Add the interface file /include/Delphi/dynapdf.pas to your project.
Add the unit dynapdf in the uses section in every source file where you want to use
Copy the dynapdf.dll into a Windows search path (e.g. Windows/System32) or into your
application directory, finished!
64 Bit Applications
Since Rad Studio XE2 you can develop 32 bit and 64 bit applications with Delphi. One thing that
is often misunderstood is where the 32 bit and 64 bit versions of dynapdf.dll must be stored. If
you develop a 32 bit application on a 64 bit Windows version then copy the 32 bit version of the
dynapdf.dll into Windows/SysWow64 and the 64 bit version into Windows/System32. Yes, this
is correct!
Both versions can be used simultaneously. Windows loads automatically the right version if
you have copied the DLLs into the right directories.
Note that the DLL should be copied into the system folder on your development machine only
so that Delphi is able to load it. The installer of your application should copy the DLL into the
application directory instead.
General Usage
The Delphi interface encapsulates all DLL functions in the wrapper class TPDF. This class can
be used like any other VCL class. The class is thread-safe and can be used without
synchronization in multithreading applications.
However, some details must be known about the class. When the first instance is created, the
constructor loads the dynapdf.dll with the API function LoadLibrary(). When creating a further
instance of the wrapper class TPDF, also a new PDF instance is created inside the DLL. Each
instance of the wrapper class uses its own DLL instance.
If an instance of the wrapper class TPDF is destroyed, the destructor deletes the used PDF
instance; if no other instance uses the library then it will be unloaded with the API function

Previous topic: General Note:, Data types in C#

Next topic: Exception handling in Delphi, Using DynaPDF in Multithreading Applications