Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library
Tutorials > VBScript > Hello world — your first PDF application with VBScript
Previous | Next

Hello world — your first PDF application with VBScript

Before we starting this tutorial make sure that you've read through the previous tutorial which explains how to get up and running with VBScript and Debenu Quick PDF Library.

Step By Step

To begin with we'll declare the variables that we will use in this tutorial. You will also need to include your license key here otherwise the library will not work.

Dim ClassName
Dim LicenseKey
Dim FileName

ClassName = "DebenuPDFLibraryAX01211.dll.PDFLibrary"
LicenseKey = " ... "
FileName = "valid-license-key.pdf"

Dim QP
Dim Result

Create an instance of the Debenu Quick PDF Library object.

Set QP = CreateObject(ClassName)

Pass the license key to the UnlockKey function and then check to see if the license key is valid. The UnlockKey function returns the value 0 if the library could not be unlocked and returns the value 1 if the library could be unlocked. It's always a good idea to validate your license key before using any of the other functions in the library.

Result = QP.UnlockKey(LicenseKey)
If Result = 1 Then

Once the library has been unlocked we can then retrieve the library version using the LibraryVersion function and the LicenseInfo function.

  WScript.Echo("Library version: " + QP.LibraryVersion)
  WScript.Echo("Valid license key: " + QP.LicenseInfo)

To demonstrate the library was successfully unlocked we will also create a PDF, draw text onto it using the DrawText function and then save it to disk using the SaveToFile function.

  Call QP.DrawText(100, 500, "The license key is valid and was registered successfully.")
  If QP.SaveToFile(FileName) = 1 Then
    WScript.Echo("File " + FileName + " written successfully.")
  Else
    WScript.Echo("Error, file could not be written")
  End If
Else
   WScript.Echo("The license key is either missing or invalid.")
End If

After you've finished, don't forget to clean up after yourself (i.e. free any memory that the script has used) by clearing the Debenu Quick PDF Library object.

Set QP = Nothing

That's all there is to it. In this sample you learnt how to register the license key, create a blank PDF, draw text on the PDF and then save the PDF to disk.

The full code for this sample has been provided below.

Full Sample Code

Dim ClassName
Dim LicenseKey
Dim FileName

ClassName = "DebenuPDFLibraryAX0716.dll.PDFLibrary"
LicenseKey = " ... "
FileName = "valid-license-key.pdf"

Dim QP
Dim Result

Set QP = CreateObject(ClassName)
Result = QP.UnlockKey(LicenseKey)

If Result = 1 Then
  WScript.Echo("Library version: " + QP.LibraryVersion)
  WScript.Echo("Valid license key: " + QP.LicenseInfo)
  Call QP.DrawText(100, 500, "The license key is valid and was registered successfully.")
  If QP.SaveToFile(FileName) = 1 Then
    WScript.Echo("File " + FileName + " written successfully.")
  Else
    WScript.Echo("Error, file could not be written")
  End If
Else
   WScript.Echo("The license key is either missing or invalid.")
End If

Set QP = Nothing

Click here to download the above script as a .VBS file.

Congratulations! You've created your first PDF application using VBScript and Debenu Quick PDF Library.

Let us know what you think

We provide code samples to give you a good idea of how to use the Debenu Quick PDF Library with the language of your choice. There is a steadily growing collection of code samples to get you started, but if you suggestions for other samples you would like to see, please let us know.


© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum