Switching between the 32-bit and 64-bit ActiveX versions of Foxit Quick PDF Library (Visual C#)
The ActiveX edition of Foxit QuicK PDF Library includes support for 32-bit and 64-bit applications. To make it incredibly easy to switch between the 32-bit and 64-bit versions we provide a C# import file for the ActiveX edition to handle the behind the scenes work for you. This C# import file also means that you don’t need to add the ActiveX as a Reference in your application.
If you’re absolutely sure that you will only want to use the 32-bit version or the 64-bit version then you can just hard code in the version that you want to use by registering the relevant ActiveX (DebenuPDFLibraryAX1312.dll for 32-bit and DebenuPDFLibrary64AX1312.dll for 64-bit) and then adding it as a COM Reference in your Visual C# application. Then you could just initialize the library like this:
32-bit ActiveX
DebenuPDFLibraryAX1312.PDFLibrary DPL = new DebenuPDFLibraryAX1312.PDFLibrary();
64-bit ActiveX
DebenuPDFLibrary64AX1312.PDFLibrary DPL = new DebenuPDFLibrary64AX1312.PDFLibrary();
As you can see in the example above, a specific 32-bit or 64-bit version is hard coded which means that if you want to switch your application from 32-bit to 64-bit then you will need to add a new COM Reference to point to the new ActiveX and then change this line of code.
However, if you add the C# import file for the ActiveX edition of Foxit Quick PDF Library to your Visual C# application then you do not need to add the ActiveX COM Reference in Visual Studio and since the line of code that initializes the library is generic you will not need to adjust Foxit Quick PDF Library in anyway when changing your application from 32-bit to 64-bit or 64-bit to 32-bit or even AnyCPU.
So, lets get started:
1. Register the 32-bit and 64-bit ActiveX versions on your machine:
As a side note Foxit Quick PDF Library is installed in slightly different locations on 32-bit and 64-bit machines. On 32-bit machines the library is installed into “Program Files” but on 64-bit machines it is installed into “Program Files (x86)”. Adjust the settings below to match the version of Windows you are using.
32-bit version
regsvr32 "C:\Program Files (x86)\Debenu\PDF Library\ActiveX\DebenuPDFLibraryAX1312.dll"
64-bit version
regsvr32 "C:\Program Files (x86)\Debenu\PDF Library\ActiveX\DebenuPDFLibrary64AX1312.dll"
2. Add the C# import file for the ActiveX edition to your Visual Studio project. It is located in this directory:
C:\Program Files (x86)\Debenu\PDF Library\ActiveX\Import\CSharp
To add the C# import file to your project just drag and drop it onto the project name in the Solution Explorer in Visual Studio or right-click on your project name and select “Add > Existing Item…” and browse to the location of the C# import file and add it. Once added it should show up like this:
3. Add the DebenuPDFLibraryAX1312 namespace to the using directives section at the top of your .cs file. It should look like this:
4. Add the line of code below to one of your classes to initialize the library:
PDFLibrary DPL = new PDFLibrary();
An example of how it might look in your code:
5. Unlock the library with your license key and try calling a function to see if it’s working:
if (DPL.UnlockKey("...insert_license_key_here...") == 0)
{
MessageBox.Show("Debenu Quick PDF Library could not be unlocked.");
}
else
{
// Library has successfully been initialized
// display information about license key used
MessageBox.Show(DPL.LicenseInfo());
}
}
It’s always a good idea to check the return result of the UnlockKey function to see if a) your license key has been accepted and b) the library has been successfully initialized. Here’s a screenshot of unlocking the library and calling the LicenseInfo function to see if it is working as expected.
6. That’s it, you can now change your projects settings to x86, x64 or AnyCPU and the ActiveX edition of Foxit Quick PDF Library will automatically handle all modes.
Lastly, if you want to see if your application is running as a 32-bit or 64-bit application then you can use this code:
if(IntPtr.Size == 8)
{
// 64 bit machine
}
else if(IntPtr.Size == 4)
{
// 32 bit machine
}
This article refers to a deprecated product. If you are looking for support for Foxit PDF SDK, please click here.
Updated on May 16, 2022