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 & samples

The Apryse .NET 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. This guide focuses on the OfficeToPDFTest sample to convert Office documents to PDF and demonstrates how to build a simple app for programmatic PDF generation.

Get started video

Get started with the Apryse Server SDK on Windows using the following video. You can skip the video and follow the step-by-step instructions to get started.

Get started video for Apryse Server SDK on the Windows platform

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

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

Info

For Alpine Linux-specific instructions, see the Alpine Linux guide.

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 Linux tarball file for your processor. We'll use the .NET Core (64-bit) Linux file.
  2. Right-click the downloaded PDFNetC64.tar.gz tarball file and select Extract to....
  3. Select Home, New Folder, and then enter ApryseSamples as the folder name.
  4. Click Create, then Select to extract the tarball into your new ApryseSamples folder to run the samples. Use a different location if preferred.
  5. Navigate to /Home/ApryseSamples/PDFNetC64/Samples/LicenseKey/CS/LicenseKey.cs and double-click to open the LicenseKey.cs file before running the sample.
  6. 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}
15

7. To run the sample, navigate to /Home/ApryseSamples/PDFNetC64/Samples/OfficeToPDFTest/CS.

Info

The folder path may vary depending on the architecture and tarball you downloaded (for example, x86‑64 vs. ARM64).

8. Right-click the CS folder, then select Open in Terminal.

9. In the terminal, run this script:

Bash

1chmod +x RunTest.sh
2./RunTest.sh

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

Bash

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.

10. Go to the /Home/ApryseSamples/PDFNetC64/Samples/TestFiles/Output directory to verify these output PDF files are present:

Text

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

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

Open the PDF files to see the converted output.

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. Create a new NewApryseProject folder in your Home folder.
  2. Right-click the NewApryseProject folder and select Open in Terminal.
  3. In your terminal, create a new .NET console application:

shell

1dotnet new console

A successful output looks similar to:

shell

1The template "Console App" was created successfully.
2
3Processing post-creation actions...
4Restoring <project-path>/<project-name>.csproj:
5 Restore succeeded.

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. From the Home/NewApryseProject directory, install the Apryse SDK:

shell

1# Add the PDFTron .NET package for x64 (Intel/AMD) systems
2dotnet add package PDFTron.NET.x64
3
4# Add the PDFTron .NET package for ARM64 systems
5dotnet add package PDFTron.NET.ARM

The command downloads the .NET package from NuGet and makes the library available to your application. A successful output looks like:

shell

1Build succeeded.
2
3info : Adding PackageReference for package 'PDFTron.NET.ARM' into project '<project-path>/<project-name>.csproj'.
4info : Installed PDFTron.NET.ARM <version>.
5info : PackageReference for package 'PDFTron.NET.ARM' version '<version>' added to file '<project-path>/<project-name>.csproj'.
6log : Restored <project-path>/<project-name>.csproj.

2. Open the NewApryseProject/Program.cs file in Visual Studio Code or your preferred code editor.

3. Replace Program.cs with the following code, update your license key, and save your changes.

C#

1// Import namespaces
2using System;
3using pdftron.Common;
4using pdftron.PDF;
5using pdftron.SDF;
6
7// Create console app entry point
8namespace myApp
9{
10 class Program
11 {
12 static void Main(string[] args)
13 {
14 Console.WriteLine("Hello World!");
15
16 // Initialize Apryse SDK
17 // Replace with your demo license key
18 pdftron.PDFNet.Initialize("YOUR_LICENSE_KEY");
19
20 using(PDFDoc doc = new PDFDoc()){
21
22 // Start a new page
23 Page page = doc.PageCreate();
24
25 // Add page to document
26 doc.PagePushBack(page);
27
28 // Save document as a linearized PDF
29 doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized); // Save document as a linearized PDF
30
31 }
32 }
33 }
34}

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. Navigate to Home > NewApryseProject folder, and right-click to select Open in Terminal.
  2. In the terminal, build and launch the application:

shell

1dotnet run

A successful output looks similar to:

shell

1Hello World!
2
3PDFNet is running in demo mode.
4PackageV2: base

3. Navigate to the Home > NewApryseProject folder.

4. Verify the blank output.pdf file was generated programmatically using the Apryse Server SDK:

Text

1NewApryseProject/
2├── bin/
3├── obj/
4├── NewApryseProject.csproj
5├── output.pdf
6└── Program.cs

Now that you have successfully run an 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 Linux 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 7, 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