Foxit Quick PDF Library

Hello world: your first PDF application with C#

This tutorial is for developers are are using Foxit Quick PDF Library with C# for the first time.

To begin with add a button to your Windows Forms Application. Double-click the button to add an OnClick event, and fill in the following event code.

Lets start. Create an instance of Foxit Quick PDF Library, this line of code will vary slightly depending on if you’re using the DLL edition or the C# edition of the PDF SDK. Here is the required setup information for using the ActiveX or DLL edition of the library with C# and Visual Studio.

You only need to use the line of code for the edition of the library that you’re using.

// ActiveX Edition

DebenuPDFLibraryAX01011.PDFLibrary DPL = new DebenuPDFLibraryAX01312.PDFLibrary();

// DLL Edition

PDFLibrary DPL = new PDFLibrary("DebenuPDFLibraryDLL1312.dll");

Before you can successfully make calls to functions in the PDF API you will need to unlock the library by calling the UnlockKey function with your license key. You can also check the type of license that you’re using by calling the LicenseInfo function.

int result = DPL.UnlockKey("your_license_key");
if (result == 1)
{

When an instance of Foxit Quick PDF Library is initiated a blank document is automatically created and loaded into memory, so it’s not necessary to create a new document before starting to call drawing commands.

First we’ll set the origin for co-ordinates to be the top left corner of a page using the SetOrigin function.

Now we’ll draw some text onto the PDF file using the DrawText function. We’ll also add a link to the document using the AddLinkToWeb function.

Then save the file to disk using the SaveToFile function. Change the path in the SaveToFile function to an existing folder on your computer.

   DPL.SetOrigin(1);
   DPL.DrawText(100, 100, "Hello world from C#");
   DPL.DrawText(300, 100, "http://www.debenu.com/");
   DPL.AddLinkToWeb(290, 85, 190, 20, "http://www.debenu.com/", 1);
   DPL.SaveToFile("HelloCSharpWorld.pdf");

Display an error message if the library could not be unlocked.

}
else
{
   MessageBox.Show("Sorry, but the license key you provided could not be validated.");
}

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.

Now all you need to do is run your new application and click on the button to see this code in action. Good luck!

The full code for this sample has been provided below.

Full Sample Code

DebenuPDFLibraryAX01312.PDFLibrary DPL = new DebenuPDFLibraryAX01312.PDFLibrary(); 
// OR
PDFLibrary DPL = new PDFLibrary("DebenuPDFLibraryDLL1312.dll");

int result = DPL.UnlockKey("your_license_key"); 

if (result == 1)
{
   DPL.SetOrigin(1);
   DPL.DrawText(100, 100, "Hello world from C#");
   DPL.DrawText(300, 100, "http://www.debenu.com/");
   DPL.AddLinkToWeb(290, 85, 190, 20, "http://www.debenu.com/", 1);
   DPL.SaveToFile("HelloCSharpWorld.pdf");
}
else
{
   MessageBox.Show("Sorry, but the license key you provided could not be validated.");
}

Congratulations! You’ve created your first PDF application using C# and Foxit Quick PDF Library.

Finally, if you want to create 32-bit and 64-bit applications there is an additional tutorial that you can look at:

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

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: