> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/get-started/languages/cpp.md).

# Get Started with the Apryse Server SDK C++ PDF Library Integration

Get started quickly with the Apryse Server SDK C++ PDF library. This guide walks you through steps to integrate the Apryse Server SDK into your project. By the end, you'll be able to convert an MS Off

This guide walks you through steps to integrate the [Apryse Server SDK free trial](https://docs.apryse.com/try-now?tab-cfc13cf95cb8=server+%2F+desktop+sdk) into your project. We’ll use a C++ project as our example project throughout this guide. By the end, you’ll have built a simple PDF-generation application and be able to open, save, and close a PDF Doc.

{% tabs %}
{% tab title="Windows" %}

## Windows C++ PDF library integration

This section helps you get started with one of our samples to see the output you can create when you integrate the Apryse Server SDK into your application. It also includes instructions on how to create a C++ project, then integrate Server SDK into the project. In the end, you’ll create and open a blank PDF within your project.

## Prerequisites

Before you start:

* Install [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) (during installation, select the “Desktop Development for C++ workload” to ensure Windows SDK is included) to write, build, test, and deploy your application.
* Download Apryse’s C++ PDF Library for Windows zip file: [Apryse Server SDK 64-bit](https://docs.apryse.com/downloads/PDFNetC64.zip).
* Get your Apryse trial key.

{% @apryse-license-key/apryse-license-key platform="SERVER" variant="full" %}

{% hint style="info" %}
**Run Apryse SDK in production.**

A commercial license key is required for use in a production environment. Contact sales by [filling out our licensing form](https://apryse.com/form/contact-sales) if you want to purchase a commercial license key.
{% endhint %}

{% hint style="warning" %}
**Keep your commercial license key confidential.**

License keys are uniquely generated and strictly confidential. Don't publish or store them in any public location, including public GitHub repositories.
{% endhint %}

## 1. Run a PDFNet sample project

In this section, you will download and run the `OfficeToPDFTest` PDFNet sample module, which demonstrates the SDK's document-conversion capabilities. Upon successful completion, you will have converted a DOCX document to a PDF file while leveraging the [MS Office-to-PDF conversion API](/core/ms-office/apis.md). You can use this module as a reference implementation when integrating similar document-conversion functionality into your own applications. By running the sample, you can quickly:

* Verify the capabilities.
* Understand how to interact with the MS Office to Conversion PDF API.
* Use it as a reference for integrating similar functionality into your own application.

1. Download the [PDFNetC64.zip](https://docs.apryse.com/downloads/PDFNetC64.zip) file.
2. Extract the `PDFNetC64.zip` file to the following location: `C:\Users\YourName\PDFNetC64\PDFNetC64\Samples`. Replace `YourName` with your user name.

{% hint style="info" %}

* You can install the samples to another location if you prefer, but for this guide’s instructions, we used the location above.
* Each time a step in this guide refers to the file path: `C:\Users\YourName...` replace `YourName` with your user name.
  {% endhint %}

3. Before running the sample, you need to add your license key to the `LicenseKey.h` file. Open **Visual Studio**, select **File** > **Open** > **File...** and navigate to: `C:\Users\Your Name\PDFNetC64\PDFNetC64\Samples\LicenseKey\CPP` (CPP or CPPS folder, depending on your distribution).
4. Select the `LicenseKey.h` file and click **Open**.
5. In the `LicenseKey.h` file, scroll down to the line containing `//#define LicenseKey “YOUR_PDFTRON_LICENSE_KEY”`. Uncomment this line (remove the `//` ) and replace the words in quotes with the copy of your trial license key you generated when you completed the **Prerequisites** instructions above. Do not change any other information in this file.
6. Save your changes and close the `LicenseKey.h` file.
7. In **Visual Studio**, select **File** > **Open** > **Project/Solution** and navigate to: `C:\Users\Your Name\PDFNetC64\PDFNetC64\Samples\OfficeToPDFTest\CPP` (CPP or CPPS folder, depending on your distribution).
8. Select the `OfficeToPDFTestVC2019.vcxproj` file and click **Open**. If a **Retarget Projects** dialog displays, click **OK**.
9. From the **Main** menu, select **Build** > **Build Solution**. After building, the output pane shows **Build Completed**.
10. From the **Main** menu, select **Debug** > **Start Without Debugging**.
11. The sample code loads an Office document, converts the Office document to PDF, saves the resulting PDF, and outputs status messages to the console. For more details, you can look at additional [OfficeToPDF sample code](/core/get-started/samples/officetopdftest.md) and the [Convert MS Office (Word, Excel, PowerPoint) to PDF](/core/conversion/convert-office.md) overview.

Once the sample has finished running, a command line window opens showing the demo mode is `Done`. Press any key to close the command line window.

12. Go to your **File Explorer** and navigate to: `C:\Users\YourName\PDFNetC64\PDFNetC64\Samples\TestFiles\Output`. You will see three output PDF files (Fishermen.pdf, the\_rime\_of\_the\_ancient\_mariner.pdf, and the factsheet\_Arabic.pdf).
13. Open the PDF files to see the converted output. You have successfully run the `OfficeToPDFTest` conversion sample!
14. Close the output PDF files.

## 2. Create a new PDFNet C++ project

This section provides steps to create a simple C++ project that uses the Apryse SDK and the PDFNet library to programmatically generate a blank PDF document. With these steps, you can learn how to set up your environment, import the required libraries, and run a script that produces a valid PDF file—all without manual intervention. This example provides a practical foundation for more advanced document‑generation workflows.

1. Open **Visual Studio**.
2. Select **Create a new project and select C++ Console App**, then click **Next**.
3. In the **Project name** field, enter a **name** for your project. For this guide, we’ll name it **ApryseGetStarted**.
4. Under **Location**, enter the **file location** for your new project. For this guide, we’ll use `C:\Users\YourName\source\repos`.
5. Click **Create** and your new project opens.

{% hint style="info" %}
Note the name and location of your new project – we will refer to it below in section **4. Run your project**.
{% endhint %}

## 3. Initialize and integrate the Apryse Server SDK into your application

Before running the application, **configure** the following dependencies:

1. In the **Visual Studio** > **Solution Explorer** pane, right-click on the **ApryseGetStarted** project.
2. Select **Properties** and the **Property Pages** dialog opens.
3. At the top of the **Property Pages** dialog, under **Configuration**, select **Debug** and under **Platform**, select **x64**.
4. In the **Configuration Properties** pane, select **Debugging**. In the **Working Directory** field, enter: `$(OutDir)`.
5. In the **Configuration Properties** pane, select **C/C++** > **General**. In the **Additional Include Directories** field, enter: `C:\Users\YourName\PDFNetC64\PDFNetC64\Headers` and then click **Apply**.
6. In the **Configuration Properties** pane, select **Linker** > **General**. In the **Additional Directories** field, enter: `C:\Users\YourName\PDFNetC64\PDFNetC64\Lib` and then click **Apply**.
7. In the **Configuration Properties** pane, select **Linker** > **Input**. In the **Additional Dependencies** field, enter: `PDFNetC.lib`, click **Apply** and then click **OK**.

## 4. Run your project

This section helps you build a simple PDF-generation application.

1. In **File Explorer**, navigate to: `C:\Users\YourName\PDFNetC64\PDFNetC64\Lib` and copy the **PDFNetC.dll** file.
2. In **File Explorer**, navigate to your new project directory: `C:\Users\YourName\source\repos\ApryseGetStarted\x64\Debug` and paste the **PDFNetC.dll** file in this folder.
3. In **Visual Studio**, open **ApryseGetStarted.cpp**. Copy the following **code** and replace the default contents in the **ApryseGetStarted.cpp** file:

{% code lineNumbers="true" %}

```cpp
#include <iostream>

// Important for PDF related manipulations
#include <PDF/PDFNet.h>
#include <PDF/PDFDoc.h>

// Important for document filesystem interaction and more
#include <SDF/ObjSet.h>

using namespace pdftron;
using namespace PDF;
using namespace SDF;


int main()
{
    
    try
    {
        // This is required before any Apryse related
        // classes and methods can be properly used
        PDFNet::Initialize("YOUR_PDFTRON_LICENSE_KEY");

        PDFDoc doc;

        // Create a new page and push it into
        // the page sequence of the document.
        Page page = doc.PageCreate();
        doc.PagePushBack(page);

        // Save the document as a linearized PDF which is the most
        // popular and effective fast viewing format
        doc.Save("linearized_output.pdf", SDFDoc::e_linearized);
    }
    catch (pdftron::Common::Exception& ex)
    {
        std::cout << ex.GetMessage() << std::endl;
    }
    return 0;

    
}

```

{% endcode %}

4. Scroll down to the line containing `PDFNet::Initialize(“YOUR_PDFTRON_LICENSE_KEY”);` and replace the words in quotes with the copy of your trial license key. Save your changes and close the **ApryseGetStarted.cpp** file.
5. From the **Main** toolbar in **Visual Studio**, click on **Build** > **Build Solution** to compile the program. In the **Output** pane you will see `Build: 1 succeeded`.
6. Under the **Main** toolbar in **Visual Studio**, click on **Debug** > **Start Without Debugging**. The program runs and a command line window displays `PDFNet is running in demo mode`.
7. Press any key to close the command line window.

The sample code you just ran performs the following actions:

* Includes the required Apryse (PDFNet) header files.
* Initializes the PDFNet engine using the provided license key.
* Creates a new PDF document in memory.
* Adds a blank page to the document.
* Saves the document as a linearized PDF file.
* Terminates the PDFNet engine.
* Writes any runtime errors to the console.

8. In **File Explorer**, navigate to the project’s output directory where the PDF file has been saved (this is the location you specified in section **2. Create a new PDFNet C++ project**, **step 4** above: `C:\Users\YourName\source\repos\ApryseGetStarted\x64\Debug`).
9. Open the `linearized_output.pdf` which you created by integrating the Apryse Server SDK.

Now that you have successfully run the OfficeToPDFTest sample (in section 1) and integrated the Apryse Server SDK C++ PDF Library into your application, you can try out 50+ samples depending on your needs.

10. To try additional samples, go to section **1. Run a PDFNet sample project** > **step 2** above and choose another sample to run.

## Troubleshooting

[Older versions of Visual Studio](/core/get-started/faq/vs-other-than-2017.md) Find out more about the Visual Studio versions we support.

[Trouble setting dependencies](/core/get-started/faq/set-dependencies-with-visual-studio-cpp.md) Set dependencies for the Apryse SDK in a startup project with Visual Studio.
{% endtab %}

{% tab title="Linux" %}

## Linux C++ PDF Library Integration

This section helps you get started with one of our samples to see the output you can create when you integrate the Apryse Server SDK into your application. It also includes instructions on how to create a C++ project, then integrate Server SDK into the project. In the end, you’ll create and open a blank PDF within your project.

## Prerequisites

Before you start:

* Install [Visual Studio Code](https://code.visualstudio.com/Download) to write, build, test, and deploy your application.
* Install [GCC](https://gcc.gnu.org/releases.html) (GNU Compiler Collection) to build and compile C++ into executable programs.
* Download Apryse’s C++ PDF Library for Linux file: [Apryse Server SDK 64-bit](https://docs.apryse.com/core/get-started/languages/pages/PyDHqmTOXBxBBmUQgx8I#c++-64bit) or [64-bit ARM](https://docs.apryse.com/core/get-started/languages/pages/PyDHqmTOXBxBBmUQgx8I#c++-64bit-arm).
* Get your Apryse trial key.

{% @apryse-license-key/apryse-license-key platform="SERVER" variant="full" %}

{% hint style="info" %}
**Run Apryse SDK in production.**

A commercial license key is required for use in a production environment. Contact sales by [filling out our licensing form](https://apryse.com/form/contact-sales) if you want to purchase a commercial license key.
{% endhint %}

{% hint style="warning" %}
**Keep your commercial license key confidential.**

License keys are uniquely generated and strictly confidential. Don't publish or store them in any public location, including public GitHub repositories.
{% endhint %}

## 1. Run a PDFNet sample project

In this section, you will download and run the `OfficeToPDFTest` PDFNet sample module, which demonstrates the SDK's document-conversion capabilities. Upon successful completion, you will have converted a DOCX document to a PDF file while leveraging the [MS Office-to-PDF conversion API](/core/ms-office/apis.md). You can use this module as a reference implementation when integrating similar document-conversion functionality into your own applications. By running the sample, you can quickly:

* Verify the capabilities.
* Understand how to interact with the MS Office to Conversion PDF API.
* Use it as a reference for integrating similar functionality into your own application.

1. [Download the tarball file for Linux](https://dev.apryse.com/linux) suitable for your processor. For this guide we’ll use the [PDFNetC64.tar.gz](https://downloads.apryse.com/downloads/PDFNetC64.tar.gz) file.
2. Navigate to the **Downloads** folder, right-click on the `PDFNetC64.tar.gz` file, then select **Extract to...**
3. Select **Home**, **New Folder**, and then enter **ApryseSamples**.
4. Click **Create** to create the new folder and then click **Select** to extract the tarball file into your new folder.

The **ApryseSamples** folder is created and the tarball is extracted to the folder.

{% hint style="info" %}
You can install the samples to another location if you prefer, but for this guide’s instructions, we used the location and name above.
{% endhint %}

5. Navigate to: `/Home/ApryseSamples/PDFNetC64/Samples/LicenseKey/CPP/LicenseKey.h` and double-click to open so you can add your license key to the `LicenseKey.h` file before running the sample. (Note that the folder may be named CPP or CPPS, depending on your distribution.)
6. Scroll down to the line containing `//#define LicenseKey “YOUR_PDF_LICENSE_KEY”`. Uncomment this line (remove the `//` ) and replace the words in quotes with the copy of your trial license key you generated when you completed the **Prerequisites** instructions above. Do not change any other information in this file.
7. Save your changes and close the `LicenseKey.h` file.
8. To run the sample, navigate to: `/Home/ApryseSamples/PDFNetC64/Samples/OfficeToPDFTest/CPP`, right-click on the `CPP` folder, then select **Open in Terminal** (CPP or CPPS folder, depending on your distribution).
9. The Linux terminal opens the `OfficeToPDFTest` sample. From the project directory, in the terminal, enter the following, then press **Enter**:

{% code lineNumbers="true" %}

```sh
Make
```

{% endcode %}

Then enter the following and press **Enter**:

{% code lineNumbers="true" %}

```sh
./OfficeToPDFTest
```

{% endcode %}

10. When you run the `./OfficeToPDFTest` command, the sample code loads an Office document, converts the Office document to PDF, saves the resulting PDF, and outputs status messages to the console. For more details, you can look at additional [OfficeToPDF sample code](/core/get-started/samples/officetopdftest.md) and the [Convert MS Office (Word, Excel, PowerPoint) to PDF](/core/conversion/convert-office.md) overview.

Once the sample has finished running, you’ll see the status `Done` in the terminal.

11. In the terminal, type `exit`, then press **Enter**.
12. Navigate to: `/Home/ApryseSamples/PDFNetC64/Samples/TestFiles/Output`. You will see three output PDF files (Fishermen.pdf, the\_rime\_of\_the\_ancient\_mariner.pdf, and the factsheet\_Arabic.pdf).
13. Open the **PDF files** to see the converted output. You have successfully run the `OfficeToPDFTest` conversion sample.
14. Close the output PDF files.

## 2. Create a new PDFNet C++ project

This section provides steps to create a simple C++ project that you can, later, integrate with the Server SDK.

1. Open **Visual Studio Code** and select **File** > **Open Folder**.
2. Navigate to: `/Home/ApryseSamples/PDFNetC64/Samples`.
3. Click **Create Folder**, enter **myApp**, then click **Create**.
4. Open the `myApp` folder and create a **CPP** folder (or CPPS depending on your distribution). To exit out of the Open Folder dialog box select **Cancel**.
5. Go to the **Main** menu in **Visual Studio Code** and select **File** > **New File...**
6. In the **New File...** dialog box, enter `myAPP.cpp` and press **Enter**.
7. Navigate to: `/ApryseSamples/PDFNetC64/Samples/myApp/CPP` and click **Create File**. The `myApp.cpp` file is created.

{% hint style="info" %}
Note the name and location of your new project – we will refer to it below in section **4. Run your project**.
{% endhint %}

## 3. Initialize and integrate the Apryse Server SDK into your application

This section integrates the Apryse Server SDK and the PDFNet library to programmatically generate a blank PDF document. With these steps, you can learn how to set up your environment and import the required libraries.

1. In **Visual Studio Code**, copy the following **code** and paste it into the `myApp.cpp` file:

{% code lineNumbers="true" %}

```cpp
#include <iostream>
#include <PDF/PDFNet.h>
#include <PDF/PDFDoc.h>
#include <SDF/ObjSet.h>

using namespace pdftron;
using namespace PDF;
using namespace SDF;

int main(int argc, char** argv)
{
 try
    {
    PDFNet::Initialize("YOUR_PDFTRON_LICENSE_KEY");  // PDFNet must be initialized before accessing any Apryse API. This line should only be called once in your main function.
    PDFDoc doc;
    Page page = doc.PageCreate(); // Start a new page
    doc.PagePushBack(page);       // Add the page to the document
    doc.Save("output.pdf", SDFDoc::e_linearized);  // Save the document as a linearized PDF
    std::cout << "Hello World!" << std::endl;
    }
   catch(pdftron::Common::Exception& ex)
    {
        std::cout << ex << std::endl;
    }
    return 0;
}
```

{% endcode %}

2. Scroll down to the line containing `PDFNet::Initialize(“YOUR_PDFTRON_LICENSE_KEY”);` and replace the words in quotes with the copy of your trial license key. Save your changes and close the file.

## 4. Run your project

You’ll run the project to get a blank PDF as your output.

1. Navigate to: `/Home/ApryseSamples/PDFNetC64/Samples/myApp/CPP`, right-click on the `CPP` folder and select **Open in Terminal**.
2. To build the project, enter the following and press **Enter**:

{% code lineNumbers="true" %}

```sh
g++ myApp.cpp -I../../../Headers -L../../../Lib -lPDFNetC -lstdc++ -lpthread -lm -lc -Wl,-rpath,../../../Lib -Wl,-rpath$ORIGIN -o myApp
```

{% endcode %}

To run the application, enter the following and press **Enter**:

{% code lineNumbers="true" %}

```sh
./myApp
```

{% endcode %}

You will see a message in the terminal:

{% code lineNumbers="true" %}

```sh
PDFNet is running in demo mode.

PackageV2: base

Hello World!
```

{% endcode %}

The sample code you just ran performs the following actions:

* Includes the required Apryse (PDFNet) header files.
* Initializes the PDFNet SDK using the provided license key.
* Creates a new PDF document in memory.
* Adds a blank page to the document.
* Saves the document as a linearized PDF file.
* Terminates the PDFNet SDK.
* Outputs any runtime errors to the console.

3. Navigate to: `/Home/ApryseSamples/PDFNetC64/Samples/myApp/CPP`.
4. Open the `output.pdf` which you created by integrating the Apryse Server SDK.

Now that you have successfully run the `OfficeToPDFTest` sample (in section 1) and integrated the Apryse Server SDK C++ PDF Library into your application, you can try out 50+ samples depending on your needs.

5. To try additional samples, go to section **1. Run a PDFNet sample project** > **step 4** above and choose another sample to run.
   {% endtab %}

{% tab title="macOS" %}

## macOS C++ PDF Library Integration

This section helps you get started with one of our samples to see the output you can create when you integrate the Apryse Server SDK into your application. It also includes instructions on how to create a C++ project, then integrate Server SDK into the project. In the end, you’ll create and open a blank PDF within your project.

## Prerequisites

Before you start:

* Install [Visual Studio Code](https://code.visualstudio.com/Download) to write, build, test, and deploy your application.
* Install [GCC](https://gcc.gnu.org/releases.html) (GNU Compiler Collection) to build and compile C++ into executable programs.
* Download Apryse’s C++ PDF Library for macOS file: [Apryse Server SDK 64-bit](https://docs.apryse.com/downloads/PDFNetCMac.zip).
* Get your Apryse trial key.

{% @apryse-license-key/apryse-license-key platform="SERVER" variant="full" %}

{% hint style="info" %}
**Run Apryse SDK in production.**

A commercial license key is required for use in a production environment. Contact sales by [filling out our licensing form](https://apryse.com/form/contact-sales) if you want to purchase a commercial license key.
{% endhint %}

{% hint style="warning" %}
**Keep your commercial license key confidential.**

License keys are uniquely generated and strictly confidential. Don't publish or store them in any public location, including public GitHub repositories.
{% endhint %}

## 1. Run a PDFNet sample project

In this section, you will download and run the `OfficeToPDFTest` PDFNet sample module, which demonstrates the SDK's document-conversion capabilities. Upon successful completion, you will have converted a DOCX document to a PDF file while leveraging the [MS Office-to-PDF conversion API](/core/ms-office/apis.md). You can use this module as a reference implementation when integrating similar document-conversion functionality into your own applications. By running the sample, you can quickly:

* Verify the capabilities.
* Understand how to interact with the MS Office to Conversion PDF API.
* Use it as a reference for integrating similar functionality into your own application.

1. Download the [PDFNetCMac.zip](https://downloads.apryse.com/downloads/PDFNetCMac.zip) file.
2. Double-click the `PDFNetCMac.zip` file to unzip it.
3. In your **Documents** folder, create a new **ApryseSamples** folder for the sample files.

{% hint style="info" %}
You can install the samples to another location if you prefer, but for this guide’s instructions, we used the location and name above.
{% endhint %}

4. Move the unzipped **PDFNetCMac** folder to the new **ApryseSamples** folder.
5. In your terminal, go to the `Documents/ApryseSamples` directory and remove the quarantine attribute from all files so the sample can run:

{% code lineNumbers="true" %}

```sh
cd Documents/ApryseSamples
sudo xattr -dr com.apple.quarantine .
```

{% endcode %}

{% hint style="info" %}
Instead of using the terminal, go to **System Settings** > **Privacy & Security** and click **Open Anyway**. For more, see [opening an app on a Mac](https://support.apple.com/en-ca/guide/mac-help/mh40616/mac).
{% endhint %}

6. Open the `Documents/ApryseSamples/PDFNetCMac/Samples/LicenseKey/CPP/LicenseKey.h` file in Visual Studio Code. (Note that the folder may be named CPP or CPPS, depending on your distribution.)
7. Scroll down to the line containing `//#define LicenseKey “YOUR_PDF_LICENSE_KEY”`. Uncomment this line (remove the `//` ) and replace the words in quotes with the copy of your trial license key you generated when you completed the **Prerequisites** instructions above. Do not change any other information in this file.
8. Save your changes and close the `LicenseKey.h` file.
9. To run the sample, navigate to: `/Documents/ApryseSamples/PDFNetCMac/Samples/OfficeToPDFTest/CPP`, right-click on the `CPP` folder, then select **New Terminal at Folder** (CPP or CPPS folder, depending on your distribution).
10. The terminal opens the `OfficeToPDFTest` sample. From the project directory, in the terminal, enter the following, then press **Enter**:

{% code lineNumbers="true" %}

```sh
Make
```

{% endcode %}

Then enter the following and press **Enter**:

{% code lineNumbers="true" %}

```sh
./OfficeToPDFTest
```

{% endcode %}

11. When you run the `./OfficeToPDFTest` command, the sample code loads an Office document, converts the Office document to PDF, saves the resulting PDF, and outputs status messages to the console. For more details, you can look at additional [OfficeToPDF sample code](/core/get-started/samples/officetopdftest.md) and the [Convert MS Office (Word, Excel, PowerPoint) to PDF](/core/conversion/convert-office.md) overview.

Once the sample has finished running, you’ll see the status `Done` in the terminal.

12. In the terminal, type `exit`, then press **Enter**.
13. Navigate to: `/Documents/ApryseSamples/PDFNetCMac/Samples/TestFiles/Output`. You will see three output PDF files (Fishermen.pdf, the\_rime\_of\_the\_ancient\_mariner.pdf, and the factsheet\_Arabic.pdf).
14. Open the **PDF files** to see the converted output. You have successfully run the `OfficeToPDFTest` conversion sample.
15. Close the output PDF files.

## 2. Create a new PDFNet C++ project

This section provides steps to create a simple C++ project that you can, later, integrate with the Server SDK.

1. Open **Visual Studio Code** and select **File** > **Open Folder...**
2. Navigate to: `/Documents/ApryseSamples/PDFNetCMac/Samples`.
3. Create a new folder named **myApp**.
4. Inside `myApp`, create a folder named **CPP** (or **CPPS** depending on your distribution).
5. Open the `CPP` folder.
6. Create a new file named `myApp.cpp`.

## 3. Initialize and integrate the Apryse Server SDK into your application

This section integrates the Apryse Server SDK and the PDFNet library to programmatically generate a blank PDF document. With these steps, you can learn how to set up your environment and import the required libraries.

1. In **Visual Studio Code**, copy the following **code** and paste it into the `myApp.cpp` file:

{% code lineNumbers="true" %}

```cpp
#include <iostream>
#include <PDF/PDFNet.h>
#include <PDF/PDFDoc.h>
#include <SDF/ObjSet.h> 

using namespace pdftron;
using namespace PDF;
using namespace SDF;

int main(int argc, char** argv)
{
 try
    {
    PDFNet::Initialize("YOUR_PDFTRON_LICENSE_KEY");  // PDFNet must be initialized before accessing any Apryse API. This line should only be called once in your main function.
    PDFDoc doc;
    Page page = doc.PageCreate(); // Start a new page
    doc.PagePushBack(page);       // Add the page to the document
    doc.Save("output.pdf", SDFDoc::e_linearized);  // Save the document as a linearized PDF
    std::cout << "Hello World!" << std::endl;
    }
   catch(pdftron::Common::Exception& ex)
    {
        std::cout << ex << std::endl;
    }
    return 0;
}
```

{% endcode %}

2. Scroll down to the line containing `PDFNet::Initialize(“YOUR_PDFTRON_LICENSE_KEY”);` and replace the words in quotes with the copy of your trial license key. Save your changes and close the `myApp.cpp` file.

## 4. Run your project

You’ll run the project to get a blank PDF as your output.

1. Navigate to: `/Documents/ApryseSamples/PDFNetCMac/Samples/myApp/CPP`, right-click on the `CPP` folder and select **NewTerminal at Folder**.
2. To build the project, enter the following and press **Enter**:

{% code lineNumbers="true" %}

```sh
g++ myApp.cpp -I../../../Headers -L../../../Lib -lPDFNetC -lstdc++ -lpthread -lm -lc -Wl,-rpath,../../../Lib -Wl,-rpath$ORIGIN -o myApp
```

{% endcode %}

To run the application, enter the following and press **Enter**:

{% code lineNumbers="true" %}

```sh
./myApp
```

{% endcode %}

You will see a message in the terminal:

{% code lineNumbers="true" %}

```sh
PDFNet is running in demo mode. 

PackageV2: base  

Hello World!
```

{% endcode %}

The sample code you just ran performs the following actions:

* Includes the required Apryse (PDFNet) header files.
* Initializes the PDFNet SDK using the provided license key.
* Creates a new PDF document in memory.
* Adds a blank page to the document.
* Saves the document as a linearized PDF file.
* Terminates the PDFNet SDK.
* Outputs any runtime errors to the console.

3. Navigate to: `/Documents/ApryseSamples/PDFNetCMac/Samples/myApp/CPP`.
4. Open the `output.pdf` which you created by integrating the Apryse Server SDK.

Now that you have successfully run the `OfficeToPDFTest` sample (in section 1) and integrated the Apryse Server SDK C++ PDF Library into your application, you can try out 50+ samples depending on your needs.

5. To try additional samples, go to section **1. Run a PDFNet sample project** > **step 3** above and choose another sample to run.
   {% endtab %}
   {% endtabs %}

## Next Steps

<a href="/core/basic-operations/basics.md" class="button primary">Usage</a><a href="/core/get-started/readme.md" class="button primary">Guides</a><a href="/core/get-started/samples.md" class="button primary">Samples</a><a href="/core/get-started/readme/api.md" class="button primary">API docs</a>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/get-started/languages/cpp.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
