How to Integrate Spire.PDF for C++ in a C++ Application

Spire.PDF for C++ is a professional PDF library built for developers to read, create, edit, and convert PDF documents in any type of C++ applications. This article demonstrates how to integrate Spire.PDF for C++ into your C++ application in two different ways.

Install Spire.PDF for C++ via NuGet

Step 1

Create a C++ project in Visual Studio 2022.

How to Integrate Spire.PDF for C++ in a C++ Application

Step 2

Right-click "References" in the Solution Explorer and choose "Manage NuGet Package" in the popup menu.

How to Integrate Spire.PDF for C++ in a C++ Application

Click "Browse", search for "spire.PDF.cpp", and install it in your project.

How to Integrate Spire.PDF for C++ in a C++ Application

Step 3

Right-click "Source Files" in the Solution Explorer, choose "Add" and then "New Item".

How to Integrate Spire.PDF for C++ in a C++ Application

Create a .cpp file.

How to Integrate Spire.PDF for C++ in a C++ Application

Step 4

Click the .cpp file you just created to write code. Before starting, you need to include the header file “Spire.Pdf.o.h” by adding the following line of code to your program.

  • C++
#include "Spire.Pdf.o.h"

The code example below shows you how to create a simple PDF file using Spire.PDF for C++.

How to Integrate Spire.PDF for C++ in a C++ Application

Install Spire.PDF for C++ by Manually Importing Libraries

Step 1

Download Spire.PDF for C++ package and unzip it somewhere on your disc to get the following files.

How to Integrate Spire.PDF for C++ in a C++ Application

Step 2

Create a C++ project in Visual Studio 2022.

How to Integrate Spire.PDF for C++ in a C++ Application

Step 3

Copy the "include" folder and the "lib" folder from the product package to your project, and save them under the same folder where the .sln file exists.

How to Integrate Spire.PDF for C++ in a C++ Application

Step 4

Right-click the project name and select "Properties".

How to Integrate Spire.PDF for C++ in a C++ Application

Configure output directory. Depending on the build mode (Debug or Release) you choose, you can set the output directory to "..\lib\x64\debug" or "..\lib\x64\release".

How to Integrate Spire.PDF for C++ in a C++ Application

Step 5

Right-click "Source Files" in the Solution Explorer, choose "Add" and then "New Item".

How to Integrate Spire.PDF for C++ in a C++ Application

Create a .cpp file.

How to Integrate Spire.PDF for C++ in a C++ Application

Step 6

Click the .cpp file you just created to write code. Before starting, you need to include the following two lines of code to your program.

  • C++
#include "../include/Spire.Pdf.o.h"
#pragma comment(lib,"../lib/x64/debug/Spire.Pdf.Cpp.lib")

The code example below shows you how to create a simple PDF file using Spire.PDF for C++.

How to Integrate Spire.PDF for C++ in a C++ Application