Switching between the 32-bit and 64-bit DLL versions of Foxit Quick PDF Library (Visual Basic)
The DLL edition of Foxit Quick PDF Library includes support for 32-bit and 64-bit applications. 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.
DPL = New PDFLibrary("DebenuPDFLibraryDLL1312.dll")
DPL = New PDFLibrary("DebenuPDFLibrary64DLL1312.dll")
But if you want to be able to easily switch between using the 32-bit DLL or the 64-bit DLL we’ve got instructions for your here that demonstrate how to do that.
Location of DLL
In order for your code to load the DLL correctly you need to pass the correct path to the library when it is initialized. If the Foxit Quick PDF Library is in the same folder as the executable for the application then it is not necessary to provide a path, just the DLL filename. But if the DLL is located in the Program Files folder for example then you must provide the folder path and file name. It’s often easiest to simply include the DLL in the same folder as the executable because this ensures that no matter which version of Windows your application is installed on, the folder path won’t be an issue.
So, lets get started:
1. Add the DLL import file, in this case the DebenuPDFLibraryDLL[contentblock id=1 img=gcb.png].vb import file for Visual Basic to your Visual Studio project. It’s usually located at:
C:\Program Files (x86)\Debenu\PDF Library\DLL\Import\VB.NET
To add the 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 Visual Basic import file and add it.
2. Add the DebenuPDFLibraryDLL[contentblock id=1 img=gcb.png] declaration to the imports section at the top of your .vb file. It will need to include the name of your project and should look something like this (first part project name, second part import file name):
3. Add the following code to your project.
Imports System.Diagnostics Imports System.IO Imports VBSwitchBetweenDQPLx86andx64.DebenuPDFLibraryDLL1312 Public Class Form1 Dim DPL As PDFLibrary Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim DLLprefix Dim DLL64prefix Dim DPLVer Dim DLLName Dim LicenseKey Dim Result ' Different filename for 32-bit and 64-bit DLL DLLprefix = "DebenuPDFLibraryDLL" DLL64prefix = "DebenuPDFLibrary64DLL" DPLVer = "1312" " ' If IntPtr is 4 it means 32-bit machine, ' If IntPtr is 8 it means 64-bit machine. If IntPtr.Size = 4 Then DLLName = DLLprefix + DPLVer + ".DLL" ' Load 32-bit DLL Else DLLName = DLL64prefix + DPLVer + ".DLL" ' Load 64-bit DLL End If ' Update path to DLL if necessary. No path is required ' if DLL is in same folder as executable that's accessing it. DPL = New PDFLibrary("C:\\Program Files (x86)\\Debenu\\PDF Library\\DLL\\" + DLLName) ' Insert your trial or commercial license key here LicenseKey = "...insert_license_key_here..." ' Check if license key is valid Result = DPL.UnlockKey(LicenseKey) If Result = 0 Then MsgBox("License key is invalid.") End If End Sub Private Sub btnHelloWorld_Click(sender As System.Object, e As System.EventArgs) Handles btnHelloWorld.Click ' Test to see if library is working as expected. DPL.SetOrigin(1) DPL.DrawText(100, 100, "Hello World") DPL.SaveToFile("HelloWorld.pdf") End Sub End Class
4. That’s it, you can now change your projects settings to x86, x64 or AnyCPU and the DLL edition of Foxit Quick PDF Library will automatically handle all modes. Information on how to optimize for a particular CPU type can be found here.
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 = 4 Then ' 32 bit machine Else ' 64 bit machine End If
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