Get Started with the Apryse Server SDK C++ PDF Library Integration
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.
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.
Download the PDFNetC64.zip file.
Extract the
PDFNetC64.zipfile to the following location:C:\Users\YourName\PDFNetC64\PDFNetC64\Samples. ReplaceYourNamewith your user name.
Before running the sample, you need to add your license key to the
LicenseKey.hfile. 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).Select the
LicenseKey.hfile and click Open.In the
LicenseKey.hfile, 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.Save your changes and close the
LicenseKey.hfile.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).Select the
OfficeToPDFTestVC2019.vcxprojfile and click Open. If a Retarget Projects dialog displays, click OK.From the Main menu, select Build > Build Solution. After building, the output pane shows Build Completed.
From the Main menu, select Debug > Start Without Debugging.
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.
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).Open the PDF files to see the converted output. You have successfully run the
OfficeToPDFTestconversion sample!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.
Open Visual Studio.
Select Create a new project and select C++ Console App, then click Next.
In the Project name field, enter a name for your project. For this guide, we’ll name it ApryseGetStarted.
Under Location, enter the file location for your new project. For this guide, we’ll use
C:\Users\YourName\source\repos.Click Create and your new project opens.
3. Initialize and integrate the Apryse Server SDK into your application
Before running the application, configure the following dependencies:
In the Visual Studio > Solution Explorer pane, right-click on the ApryseGetStarted project.
Select Properties and the Property Pages dialog opens.
At the top of the Property Pages dialog, under Configuration, select Debug and under Platform, select x64.
In the Configuration Properties pane, select Debugging. In the Working Directory field, enter:
$(OutDir).In the Configuration Properties pane, select C/C++ > General. In the Additional Include Directories field, enter:
C:\Users\YourName\PDFNetC64\PDFNetC64\Headersand then click Apply.In the Configuration Properties pane, select Linker > General. In the Additional Directories field, enter:
C:\Users\YourName\PDFNetC64\PDFNetC64\Liband then click Apply.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.
In File Explorer, navigate to:
C:\Users\YourName\PDFNetC64\PDFNetC64\Liband copy the PDFNetC.dll file.In File Explorer, navigate to your new project directory:
C:\Users\YourName\source\repos\ApryseGetStarted\x64\Debugand paste the PDFNetC.dll file in this folder.In Visual Studio, open ApryseGetStarted.cpp. Copy the following code and replace the default contents in the ApryseGetStarted.cpp file:
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.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.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.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.
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).Open the
linearized_output.pdfwhich 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.
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.
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 to write, build, test, and deploy your application.
Install GCC (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 or 64-bit ARM.
Get your Apryse trial key.
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.
Download the tarball file for Linux suitable for your processor. For this guide we’ll use the PDFNetC64.tar.gz file.
Navigate to the Downloads folder, right-click on the
PDFNetC64.tar.gzfile, then select Extract to...Select Home, New Folder, and then enter ApryseSamples.
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.
Navigate to:
/Home/ApryseSamples/PDFNetC64/Samples/LicenseKey/CPP/LicenseKey.hand double-click to open so you can add your license key to theLicenseKey.hfile before running the sample. (Note that the folder may be named CPP or CPPS, depending on your distribution.)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.Save your changes and close the
LicenseKey.hfile.To run the sample, navigate to:
/Home/ApryseSamples/PDFNetC64/Samples/OfficeToPDFTest/CPP, right-click on theCPPfolder, then select Open in Terminal (CPP or CPPS folder, depending on your distribution).The Linux terminal opens the
OfficeToPDFTestsample. From the project directory, in the terminal, enter the following, then press Enter:
Then enter the following and press Enter:
When you run the
./OfficeToPDFTestcommand, 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, you’ll see the status Done in the terminal.
In the terminal, type
exit, then press Enter.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).Open the PDF files to see the converted output. You have successfully run the
OfficeToPDFTestconversion sample.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.
Open Visual Studio Code and select File > Open Folder.
Navigate to:
/Home/ApryseSamples/PDFNetC64/Samples.Click Create Folder, enter myApp, then click Create.
Open the
myAppfolder and create a CPP folder (or CPPS depending on your distribution). To exit out of the Open Folder dialog box select Cancel.Go to the Main menu in Visual Studio Code and select File > New File...
In the New File... dialog box, enter
myAPP.cppand press Enter.Navigate to:
/ApryseSamples/PDFNetC64/Samples/myApp/CPPand click Create File. ThemyApp.cppfile is created.
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.
In Visual Studio Code, copy the following code and paste it into the
myApp.cppfile:
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.
Navigate to:
/Home/ApryseSamples/PDFNetC64/Samples/myApp/CPP, right-click on theCPPfolder and select Open in Terminal.To build the project, enter the following and press Enter:
To run the application, enter the following and press Enter:
You will see a message in the terminal:
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.
Navigate to:
/Home/ApryseSamples/PDFNetC64/Samples/myApp/CPP.Open the
output.pdfwhich 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.
To try additional samples, go to section 1. Run a PDFNet sample project > step 4 above and choose another sample to run.
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 to write, build, test, and deploy your application.
Install GCC (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.
Get your Apryse trial key.
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.
Download the PDFNetCMac.zip file.
Double-click the
PDFNetCMac.zipfile to unzip it.In your Documents folder, create a new ApryseSamples folder for the sample files.
Move the unzipped PDFNetCMac folder to the new ApryseSamples folder.
In your terminal, go to the
Documents/ApryseSamplesdirectory and remove the quarantine attribute from all files so the sample can run:
Open the
Documents/ApryseSamples/PDFNetCMac/Samples/LicenseKey/CPP/LicenseKey.hfile in Visual Studio Code. (Note that the folder may be named CPP or CPPS, depending on your distribution.)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.Save your changes and close the
LicenseKey.hfile.To run the sample, navigate to:
/Documents/ApryseSamples/PDFNetCMac/Samples/OfficeToPDFTest/CPP, right-click on theCPPfolder, then select New Terminal at Folder (CPP or CPPS folder, depending on your distribution).The terminal opens the
OfficeToPDFTestsample. From the project directory, in the terminal, enter the following, then press Enter:
Then enter the following and press Enter:
When you run the
./OfficeToPDFTestcommand, 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, you’ll see the status Done in the terminal.
In the terminal, type
exit, then press Enter.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).Open the PDF files to see the converted output. You have successfully run the
OfficeToPDFTestconversion sample.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.
Open Visual Studio Code and select File > Open Folder...
Navigate to:
/Documents/ApryseSamples/PDFNetCMac/Samples.Create a new folder named myApp.
Inside
myApp, create a folder named CPP (or CPPS depending on your distribution).Open the
CPPfolder.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.
In Visual Studio Code, copy the following code and paste it into the
myApp.cppfile:
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 themyApp.cppfile.
4. Run your project
You’ll run the project to get a blank PDF as your output.
Navigate to:
/Documents/ApryseSamples/PDFNetCMac/Samples/myApp/CPP, right-click on theCPPfolder and select NewTerminal at Folder.To build the project, enter the following and press Enter:
To run the application, enter the following and press Enter:
You will see a message in the terminal:
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.
Navigate to:
/Documents/ApryseSamples/PDFNetCMac/Samples/myApp/CPP.Open the
output.pdfwhich 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.
To try additional samples, go to section 1. Run a PDFNet sample project > step 3 above and choose another sample to run.
Next Steps
Last updated
Was this helpful?