Get started with the Apryse Server SDK .NET 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 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 and 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 and samples

This get-started guide explains how to install and use the Apryse Server SDK in a .NET application. It includes the full .NET PDF library and sample modules. We'll focus on the OfficeToPDFTest sample to convert Office documents to PDF and demonstrate how to build a simple app for programmatic PDF generation.

Get started video

Get started with the Apryse Server SDK and .NET on Windows by watching this 4-minute video. You can skip the video and follow the step-by-step instructions instead.

Get started video for Apryse Server SDK on the Windows platform

To get started, choose your preferred platform from the following tabs.

Windows .NET PDF library integration

In this guide, you'll explore sample PDFNet projects to understand the types of PDF outputs you can create with the Apryse Server SDK. You'll also create a simple .NET application, add the Apryse Server SDK, and learn how to generate files programmatically.

Prerequisites

Before you start:

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 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. Convert DOCX to PDF

In this section, you’ll use the OfficeToPDFTest sample to convert a DOCX file to PDF using the Microsoft Office conversion API. You can use this sample to understand how document conversion works and as a reference for your own implementations.

  1. Download the PDFNetC64.zip file.
  2. Unzip the PDFNetC64.zip file to this location. Use a different location if preferred:

Text

1C:\Users\<your_name>\PDFNetC64\Samples\

3. To add your license key, open this file in Visual Studio Code:

Text

1C:\Users\<your_name>\PDFNetC64\Samples\LicenseKey\CS\LicenseKey.cs

4. Go to the private static string key = “YOUR_PDFTRON_LICENSE_KEY”; line and replace the quoted text with your trial license key. Don't change any other information in this file. Save your changes.

C#

LicenseKey.cs

1public static class PDFTronLicense
2{
3 // Add your trial license key here
4 private static string key = "YOUR_PDFTRON_LICENSE_KEY";
5 public static string Key
6 {
7 get
8 {
9 if (key == "YOUR_PDFTRON_LICENSE_KEY" || key == "")
10 throw (new System.Exception("Please enter your license key by replacing \"YOUR_PDFTRON_LICENSE_KEY\" that is assigned to the static string key variable in Samples/LicenseKey/CS/LicenseKey.cs. If you do not have a license key, please go to https://www.pdftron.com/pws/get-key to obtain a demo license or https://www.pdftron.com/form/contact-sales to obtain a production key."));
11 return key;
12 }
13 }
14}

5. Open PowerShell as an administrator, replace <your_name> , and navigate to this directory:

PowerShell

1cd C:\Users\<your_name>\PDFNetC64\Samples\OfficeToPDFTest\CS

6. From the OfficeToPDFTest\CS directory, run this script:

PowerShell

1.\RunTest.bat

When you run the .\RunTest.bat command, the sample code loads a Microsoft Office document, converts it to PDF, saves the PDF, and writes the following status messages to the console. For more details, review the OfficeToPDF sample code and the Convert MS Office (Word, Excel, PowerPoint) to PDF overview.

PowerShell

1PDFNet is running in demo mode.
2PackageV2: base
3PackageV2: office_conversion
4Saved Fishermen.pdf
5Saved the_rime_of_the_ancient_mariner.pdf
6Saved factsheet_Arabic.pdf
7Done.

7. Go to this directory to verify that the output PDF files are present:

Text

1C:\Users\<your_name>\PDFNetC64\Samples\TestFiles\Output

The folder structure looks similar to:

Text

1Samples/TestFiles/Output/
2├── factsheet_Arabic.pdf
3├── Fishermen.pdf
4├── the_rime_of_the_ancient_mariner.pdf

8. Open the PDF files to see the converted output. The original DOCX files are located in the PDFNetC64\Samples\TestFiles folder.

Converted PDF file showing the output generated from a DOCX document

Converted PDF file showing the output generated from a DOCX document

2. Create a .NET PDF app

Create a simple .NET application that uses the Apryse Server SDK and PDFNet library to generate a PDF programmatically. In this section, you’ll set up a minimal project, add the required code, and run a script that creates a blank PDF document. This example provides a practical foundation for building more advanced document‑generation workflows.

Set up your project

Set up your project by creating a folder and preparing your workspace for the application.

  1. Open Visual Studio and go to File > New > Project.
  2. When creating a new project, select Console App, then click Next.
  3. Add a Project name.
  4. Specify where to save your project using the Location field, then click Next.

Info

Remember the file location for your project. You'll need it later when verifying this workflow.

5. In the Framework dropdown, select the .NET version. For example, .NET 8 (Long Term Support), then click Create. A default app is created, where you can run and debug your project.

Add the SDK to your app

Next, integrate the Apryse Server SDK into your .NET application and add the code needed to generate a PDF.

  1. In Visual Studio, go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
  2. From the Browse tab, enter Apryse in the Search field. This shows you the various packages that Apryse has published.
  3. From the search results, select PDFTron.NET.x64.
  4. In the Manage Packages for Solution dialog, select the project, then click Install.
Visual Studio Manage NuGet Packages window showing the PDFTron.NET.x64 package with version options and an Install button.

Manage NuGet Packages dialog in Visual Studio with PDFTron.NET.x64 installation options.

5. In the Preview Changes modal, click Apply to install the package in your project.

6. Check the Output window (Package Manager) to confirm the installation completed successfully:

Text

1Restoring packages...
2Installed PDFTron.NET.x64 11.12.1 from...
3Installing NuGet package PDFTron.NET.x64 11.12.1...
4Generating MSBuild file...
5Writing assets file to disk...
6Successfully installed 'PDFTron.NET.x64'
7========== Finished ==========

7. Go to the Program.cs file in the Solutions Explorer. Replace the entire file with this code, making sure to update your license key and save the file:

C#

Program.cs

1// Import namespaces
2using System;
3using pdftron;
4using pdftron.Common;
5using pdftron.PDF;
6using pdftron.SDF;
7
8// Create console app entry point
9namespace myApp
10{
11 class Program
12 {
13 static void Main(string[] args)
14 {
15 Console.WriteLine("Hello World!");
16
17 // Initialize Apryse SDK
18 // Replace with your demo license key
19 PDFNet.Initialize("YOUR_LICENSE_KEY");
20
21 // Using PDFNet related classes and methods, must
22 // catch or throw PDFNetException
23 try
24 {
25 using (PDFDoc doc = new PDFDoc())
26 {
27 doc.InitSecurityHandler();
28 // Start a new page
29 Page newPg = doc.PageCreate();
30
31 // Add page to document
32 doc.PagePushBack(newPg);
33
34 // Save document as a linearized PDF
35 doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
36 System.Console.WriteLine("Done. Results saved in linearized_output.pdf");
37 }
38 }
39 catch (PDFNetException e)
40 {
41 System.Console.WriteLine(e.Message);
42 }
43 // Make the program wait to terminate after user input
44 Console.ReadKey();
45 }
46 }
47}

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

With this code, you can:

  • Initialize the system by logging a startup message.
  • Import the .NET SDK.
  • Define an asynchronous Main function to generate the PDF, while the PDFNet engine handles license initialization and cleanup.
  • Log errors and, once processing is complete, release PDFNet resources and shut down the engine.

Run and verify your setup

Finally, build and run your application to confirm that the Apryse Server SDK is working correctly. After the application runs successfully, it will generate a blank PDF file locally.

  1. In Visual Studio, run the app by selecting the Start button on the toolbar, or by pressing F5. A successful output looks similar to:

Command Prompt

1Hello World!
2
3PDFNet is running in demo mode.
4PackageV2: base
5Done. Results saved in linearized_output.pdf

2. Navigate to this directory, where the build output is created by default:

Text

1C:\Users\<your_name>\source\repos\<project_name>\bin\Debug\<target_framework\

3. Verify the blank output.pdf file was generated programmatically using the Apryse Server SDK. The folder structure looks similar to:

Text

1C:\Users\<your_name>\source\repos\
2└── apryse-console-app\
3 ├── apryse-console-app.sln
4 └── apryse-console-app\
5 └── bin\
6 └── Debug\
7 └── net8.0\
8 ├── apryse-console-app.deps.json
9 ├── apryse-console-app.dll
10 ├── apryse-console-app.exe
11 ├── apryse-console-app.pdb
12 ├── apryse-console-app.runtimeconfig.json
13 ├── libPDFNetC.dylib
14 ├── libPDFNetC.so
15 ├── PDFNetC.dll
16 ├── PDFTronDotNet.dll
17 └── output.pdf

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

File explorer window on a Windows system showing the Apryse Samples library installed

You can try over fifty samples for the Apryse Server SDK.

To try additional samples, go to section 1. Convert DOCX to PDF > step 6 and choose another sample to run.

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