Some test text!
Core / Guides / C++
Welcome to Apryse. C++ for the Apryse SDK is cross-platform and supported on Windows and Linux. To get started, choose your preferred platform from the tabs below.
Windows
Linux
macOS
This guide will help you run Apryse samples and integrate a free trial of the Apryse SDK into C++ applications on Windows. Your free trial includes unlimited trial usage and support from solution engineers.
Make sure that the Desktop development with C++
workload and Windows 8.1 SDK
are part of your installation.
This guide will use Visual Studio 2017.
The Troubleshooting section has information about other versions.
Apryse's C++ PDF library for Windows:
This article uses PDFNET_BASE
as the path into the folder that you extracted.
PDFNET_BASE = path/to/extraction/folder/PDFNetC(64)/
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.
Navigate to the location of extracted contents. Find and enter the Samples
folder (PDFNET_BASE/Samples
). Here you can find sample code for a large number of features supported by the Apryse SDK.
Find Samples_VC20XX.sln
inside the Samples
folder and open it with Visual Studio. Choose the appropriate solution based on your Visual Studio installation.
Run a specific sample
Find the sample you want to run and set it as the Startup project.
If you're running into issues, see the Troubleshooting section.
Run the project.
Run all samples
If you prefer using command line to compile and run code, have a look at the Advanced section.
This section will help you build the "Apryse Hello World" application. It is easy to integrate the rest of Apryse SDK if you are able to open, save and close a PDFDoc.
Before writing the application, some dependencies needed to be with Visual Studio.
myapp
.PDFNET_BASE\Lib\PDFNetC.lib
to the project's Additional Dependencies in the Linker Input settings.PDFNET_BASE\Headers
to the project's Additional Include Directories in the C/C++ General Settings.PDFNET_BASE\Lib\PDFNetC.dll
file to the project's output directory. Verify that the right version of PDFNetC.dll
was added from the path used to add the reference.The Troubleshooting section has more detailed instructions for newcomers to Visual Studio.
Replace the contents of myapp.cpp
with:
``` 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_APRYSE_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;
}
```
You can use the Local Windows Debugger
button to build the solution and run the main function.
Once the code has been run, you can find a new document called linearized_output.pdf
in the output directory of your project.
You can learn about and add more features by reading our guides , samples and API.
Run samples using batch files and command prompt
Navigate into the folder for any sample that you like (PDFNET_BASE/Samples/X
).
Create a new file inside the CPP
folder called RunTest.bat
. Paste the following code in it (replace X with the name of the Test folder):
@echo off
setlocal
REM Replace X with the name of the Test folder, Ex. FDFTest
set TEST_NAME=X
if not exist PDFNetC.dll copy "%cd%\..\..\..\Lib\PDFNetC.dll" PDFNetC.dll
cl /EHsc /I"../../../Headers" ../../../Lib/PDFNetC.lib %TEST_NAME%.cpp
%TEST_NAME%.exe
endlocal
PAUSE
Save the file.
Open the Windows Start Menu and in Apps, scroll down and find the Visual Studio 2019 folder (not application). Expand it and click on Developer Command Prompt for Visual Studio 2017
. Navigate to the test folder on your system.
Use the following to compile, build and run the test:
RunTest.bat
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.
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales