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

The Apryse Server SDK is cross-platform and supported on Windows, Linux, and macOS. The base package is robust, allowing you to programmatically do the following and more with PDFs:

Additional functionality

If you’re looking for additional capabilities, we offer add-on packages, such as Smart Data Extraction, and add-on modules, such as Office Conversion. For a complete list of add-ons, refer to the following:

Solutions & benefits

Using the Server SDK allows you to build server-side document processing solutions at scale without relying on client devices or cloud APIs. Since the Server runs entirely on-premises (or in your private cloud), you can ensure security and compliance with full control over access, storage, and encryption. You can also easily integrate with web apps, backend systems, document management systems, and content workflows.

Steps & samples

This guide walks you through steps to integrate the Apryse Server SDK free trial 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.

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  (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.
  • Get your Apryse trial key.

License Key

Apryse collects some data regarding your usage of the SDK for product improvement.

If you wish to continue without data collection, contact us and we will email you a no-tracking trial key for you to get started.

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 if you want to purchase a commercial license key.

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.

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. 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 file.
  2. Extract the PDFNetC64.zip file to the following location: C:\Users\YourName\PDFNetC64\PDFNetC64\Samples. Replace YourName with your user name.
  • 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.

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 and the Convert MS Office (Word, Excel, PowerPoint) to PDF 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.

Note the name and location of your new project – we will refer to it below in section 4. Run your project.

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:

C++

1#include <iostream>
2
3// Important for PDF related manipulations
4#include <PDF/PDFNet.h>
5#include <PDF/PDFDoc.h>
6
7// Important for document filesystem interaction and more
8#include <SDF/ObjSet.h>
9
10using namespace pdftron;
11using namespace PDF;
12using namespace SDF;
13
14
15int main()
16{
17
18 try
19 {
20 // This is required before any Apryse related
21 // classes and methods can be properly used
22 PDFNet::Initialize("YOUR_PDFTRON_LICENSE_KEY");
23
24 PDFDoc doc;
25
26 // Create a new page and push it into
27 // the page sequence of the document.
28 Page page = doc.PageCreate();
29 doc.PagePushBack(page);
30
31 // Save the document as a linearized PDF which is the most
32 // popular and effective fast viewing format
33 doc.Save("linearized_output.pdf", SDFDoc::e_linearized);
34 }
35 catch (pdftron::Common::Exception& ex)
36 {
37 std::cout << ex.GetMessage() << std::endl;
38 }
39 return 0;
40
41
42}
43

4. 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.

5. 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.

6. 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.

7. 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).

8. 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.

9. 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
Find out more about the Visual Studio versions we support.

Trouble setting dependencies
Set dependencies for the Apryse SDK in a startup project with Visual Studio.

Next Steps

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales