---
title: "Add PDF functionality with Visual C++ with MFC"
canonical_url: "https://www.nutrient.io/sdk/dotnet/getting-started/com-activex-visual-cplus-with-mfc/"
md_url: "https://www.nutrient.io/sdk/dotnet/getting-started/com-activex-visual-cplus-with-mfc.md"
last_updated: "2026-05-21T17:12:02.379Z"
description: "Learn how to integrate Nutrient .NET SDK into your application. Step-by-step guide for document processing, PDF conversion, and manipulation."
---

# Add PDF functionality with Visual C++ with MFC

This guide explains how to integrate Nutrient.NET SDK (formerly known as GdPicture.NET SDK) into your application.

## About Nutrient.NET SDK

Nutrient.NET SDK is a cross-platform developer solution for building intelligent PDF and document processing applications. This toolkit enables you to compose, display, capture, edit, and print documents. You can build applications using Nutrient.NET SDK with numerous development environments and deploy these applications to different platforms.

## Prerequisites

Before proceeding with this guide, ensure your development environment meets the following requirements.

###.NET 8.0 or higher (cross-platform)

-.NET SDK 8.0 or higher — Install the latest stable version from the [Microsoft website](https://dotnet.microsoft.com).

- Supported operating systems — Windows, macOS, and Linux.

- Development tools — Visual Studio 2022 (17.6+) or Visual Studio Code with C# extension.

- Command-line tools — Ensure the.NET CLI is available and configured in your system path.

###.NET Framework 4.6.2 or higher (Windows)

-.NET Framework 4.6.2+ — Preinstalled on Windows or available from the official Microsoft Download Center.

- Supported operating systems — Windows 10 or later.

- Development tools — Visual Studio 2019 (or newer) with the **.NET framework development** workload installed.

For more information on the supported frameworks and operating systems, refer to our [system compatibility](https://www.nutrient.io/guides/dotnet/about/system-compatibility.md) guide.

## Installing Nutrient.NET SDK

The best way to install Nutrient.NET SDK is through NuGet repositories. To view a list of available packages, refer to the [download Nutrient.NET](https://www.nutrient.io/guides/dotnet/downloads.md) guide.

Alternatively, use our ready-made bootstrap project for new setups.

[Download example project](https://www.nutrient.io/downloads/GdPictureBootstrap.zip)





## Activating the trial license

To activate a trial license, follow the steps below:

1. In Visual Studio, create a `LicenseManager` object in the code file where the application loads before using any of the methods of Nutrient.NET SDK.

2. Pass the license key to the `RegisterKEY` method of the `LicenseManager` object.

> Set the license using the `LicenseManager` once before making any calls to the SDK. This activates the license for the entire assembly. Make sure your application initializes and sets the license only once.

### C#

```csharp

LicenseManager licenseManager = new LicenseManager();
licenseManager.RegisterKEY("");

```

### VBNET

```vbnet

Dim licenseManager As New LicenseManager
licenseManager.RegisterKEY("")

```

### CPPMFC

```cppmfc

CLicenseManager licenseManager;
licenseManager.CreateDispatch(L"GdPicture14.LicenseManager");
licenseManager.RegisterKEY(L"");

```

### UNMANAGEDCPP

```unmanagedcpp

BSTR bstrLicense = ::SysAllocString(L"");
if (bstrLicense!= NULL)
{
   _LicenseManagerPtr licenseManager(__uuidof(LicenseManager));
   VARIANT_BOOL result = licenseManager->RegisterKEY(bstrLicense);
   ::SysFreeString(bstrLicense);
}

```

### CPPBUILDER

```cppbuilder

BSTR bstrLicense = ::SysAllocString(L"");
if (bstrLicense!= NULL)
{
   _LicenseManagerPtr licenseManager;
   licenseManager = (_LicenseManagerPtr)CreateComObject(CLSID_LicenseManager);
   licenseManager->RegisterKEY(bstrLicense);
   ::SysFreeString(bstrLicense);
   bstrLicense = NULL;
}

```

### DELPHI

```delphi

var
   LicenseManager1: Variant;
begin
   LicenseManager1 := CreateOleObject('GdPicture14.LicenseManager');
   LicenseManager1.RegisterKey('');

```

### JAVASCRIPT

```js

var licenseManager;
licenseManager = new ActiveXObject("GdPicture14.LicenseManager");
licenseManager.RegisterKey("");

```

### POWERBUILDER

```powerbuilder

long ll_result
OLEObject licenseManager
licenseManager = CREATE OLEObject
ll_result = licenseManager.ConnectToNewObject("GdPicture14.LicenseManager")
licenseManager.RegisterKey("")

```

### VB6

```vb6

Dim licenseManager As New LicenseManager
Call licenseManager.RegisterKEY("")

```

### VBA

```vba

Dim licenseManager As New GdPicture_NET_14.LicenseManager
licenseManager.RegisterKey ("")

```

Leaving the license key as an empty string activates the SDK in trial mode. After purchasing a commercial license, replace the empty string with your license key.

> Starting from version 14.2.94, a trial key is no longer required. As shown in the examples above, setting the key to an empty string ("") enables trial mode.

## Integrating with Visual C++ with MFC

This section provides you with a step-by-step guide to getting started using Nutrient.NET SDK with Visual C++ (up to VS 2017) with an MFC environment.

You can find an example using COM Interop in the `[INSTALLATION FOLDER]\Samples\WinForm\c++ mfc` folder.

> IntelliSense is fully supported in Visual C++.

1. Start a new project in **Visual Studio**  > **File** > **New** > **Project**. Then select **MFC/ATL > MFC Application**.

2. Set your **Application Type** to **Dialog based**.

3. Copy `GdPicture.NET.14.dll` and `GdPicture.NET.14.tlb` to your application folder.

4. To import the DLL, use **Project** > **Class Wizard** (available until VS 2017), choose the **Add Class...** dropdown, and select **MFC Class From TypeLib...**

5. Under **Add class from:** in the wizard dialog, select **File**. Then, click the **...** button on the right-hand side, next to the **Location** field, to select the `GdPicture.NET.14.tlb` file located in `[INSTALLDIR]/Redist/COM Interop` or in your application directory if you copied it.

6. Select the interfaces you need from the list to generate the C++ wrappers.

   > Each Nutrient.NET SDK class, which also contains events, will be split into two classes: one defining events, and another one defining properties and methods. For example, to import the `GdPicturePDF` class, select `__GdPicturePDF` and `GdPicturePDF`.

7. Change the way the DLL is imported in generated header files (if needed). Change `no_namespace` to `raw_interfaces_only` in the `#import` code line in the generated headers.

8. Initialize COM objects in your application by adding `HRESULT hr = CoInitialize(NULL);` under the main function.

9. Include the generated headers in your file and build the application.

## GdViewer integration

This section provides you with a step-by-step guide to getting started creating a simple MFC application using Nutrient.NET SDK with Visual C++ (up to VS 2017) and containing a GdViewer ActiveX component.

You can find an example using COM Interop in the `[INSTALLATION FOLDER]\Samples\WinForm\c++ mfc` folder.

### Integration

1. Start a new project in **Visual Studio** > **File** > **New** > **Project**. Then select **Visual C++** > **MFC/ATL** > **MFC Application**. Write the project name and confirm.

2. Set your **Application Type** to **Dialog based**. Copy `GdPicture.NET.14.(64).dll` and `GdPicture.NET.14.tlb` to your application folder.

3. To import the installed Nutrient.NET SDK toolkit (DLL) and to integrate the GdViewer control, you need to follow two steps.

   To import as an ActiveX control:

   - Use **Project** > **Class Wizard** (available until VS 2017) and select the **Add Class** dropdown. Then, choose **MFC Class From ActiveX Control...** This is necessary for controls like GdViewer.
   - The window with the wizard will appear, and from the **Available ActiveX controls** list, choose **GdPicture14.GdViewer**.

   - From the **Interfaces** list, choose **IGdViewer** and add it to the **Generated classes** list. Then click **Finish** and press **OK**.

   To import from `TypeLib`:

   - Use **Project** > **Class Wizard** (available until VS 2017) and select the **Add Class** dropdown. Then, choose **MFC Class From TypeLib...**
   - The window with the wizard will appear, and from the **Available type libraries** list, choose **GdPicture14 - Document Imaging**.

   - From the **Interfaces** list, choose **ILicenseManager** and **\_\_GdViewer** and add them to the **Generated classes** list. Then click **Finish** and press **OK**.

4. Initialize COM objects in your application by adding `HRESULT hr = CoInitialize(NULL);` under the main function.

   Here’s the adapted source code:

   ```

   BOOL CdemoApp::InitInstance()
    {...
      InitCtrls.dwICC = ICC_WIN95_CLASSES;
      InitCommonControlsEx(&InitCtrls);

      CWinApp::InitInstance();
      HRESULT hr = CoInitialize(NULL);...
    }

   ```

5. Include the generated headers in your file and build the application.

   Here’s the adapted source code:

   ```

     // Add GdViewer control to the `demoDlg.h` file:
     class CdemoDlg : public CDialogEx
     {
     // Construction
     public:
         CGdViewer sampleView;...
     }

     // Include headers in the `demoDlg.cpp` file:
     #include "C_GdViewer.h"

     #include "CLicenseManager.h"

   ```

### Adding code to initialize the GdViewer component

1. Your default solution will look like what’s shown below. In **Resource View**, select `Dialog/IDD_DEMO_DIALOG`.

2. When the form appears, choose **Button** from the toolbox on the left side and place it on the form.

3. Double-click the form, and the method for the button click will appear.

4. Update it with this code:

   ```

   const int CTRL_ID = 280;
   void CdemoDlg::OnBnClickedButton1()
    {
      // TODO: Add your control notification handler code here.
      CLicenseManager oLicenseManager;
      oLicenseManager.CreateDispatch(L"GdPicture14.LicenseManager");
      oLicenseManager.RegisterKEY(L" XXX ");

      // Create the control, but make sure to use `WS_CHILD` and `WS_VISIBLE`.
      if (!sampleView.Create(L"PdfWnd", WS_CHILD | WS_VISIBLE, CRect(0, 0, 200, 200), this, CTRL_ID))
          {
            AfxMessageBox(L"Failed to create GdViewer control");
             return;
         }

      // Sample init settings — not necessary.
      sampleView.put_EnableMenu(false);
      sampleView.put_ContinuousViewMode(TRUE);
      sampleView.put_MouseWheelMode(2);
      sampleView.put_ScrollBars(TRUE);
      sampleView.DisplayFromFile(L"image.jpg");
      sampleView.Redraw();
   }
   ```

### Adding code to dispose of the GdViewer component

The following example shows how you can release the GdViewer component. What’s important to note is that you need to dispose of the objects properly.

1. Add a new method for handling the `Close()` message by choosing **Resource View** > **Demo** > **Dialog** > **IDD\_DEMO\_DIALOG**.

2. Select the form that appears.

3. Click the messages icon in the properties bar.

4. Double-click the field next to `WM_CLOSE`. This will give you the option to create a method for handling `Close()` messages.

5. Add the following code to the method you just created:
   - `sampleView.CloseDocument();`
   - `sampleView.Dispose();`

To handle the `Close()` message, use the following code:

```

// The result will look like this:
void CdemoDlg::OnClose()
{
  // TODO: Add your message handler code here and/or call default.
  CDialogEx::OnClose();
  sampleView.CloseDocument();
  sampleView.Dispose();
}

```
---

## Related pages

- [Add PDF functionality with Delphi and C++ Builder](/sdk/dotnet/getting-started/com-activex-delphi-cplus-builder.md)
- [Add PDF functionality with Microsoft Access](/sdk/dotnet/getting-started/com-activex-microsoft-access.md)
- [Add PDF functionality with Visual FoxPro](/sdk/dotnet/getting-started/com-activex-visual-foxpro.md)
- [Add PDF functionality with Visual Basic](/sdk/dotnet/getting-started/com-activex-visual-basic.md)
- [Getting started with Nutrient .NET SDK](/sdk/dotnet/getting-started.md)
- [Add PDF functionality with WPF](/sdk/dotnet/getting-started/wpf.md)
- [Add PDF functionality with WinForms](/sdk/dotnet/getting-started/winforms.md)
- [Add PDF functionality with .NET](/sdk/dotnet/getting-started/integrate.md)

