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.

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: C:\Users\YourName\PDFNetC64\Samples\. Use a different location if preferred.
  3. Open the C:\Users\YourName\PDFNetC64\Samples\LicenseKey\CS\LicenseKey.cs file in Visual Studio.
  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, navigate to this directory, and replace <your_name> :

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 the C:\Users\YourName\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

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

This section provides steps to create a simple .NET 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.

  1. Open Visual Studio.
  2. Select Create a new project to create a new console app, then click Next.
Apryse Docs Image

Create a new project in Visual Studio.

3. In the Project name field, enter a name for your project.

4. Under Location, enter the file location where you want the project to be created, then click Next.

Apryse Docs Image

Add a project name and location where you want the project to be saved.

Note the file location of the project you just entered - you will need it later in section 3. Integrate the Apryse Server SDK into your application below.

5. In the Framework drop-down menu, click on the version you want to use (for example .NET 8), then click Create.

Apryse Docs Image

Choose the version of the .NET Framework you will be using.

A default app scaffolds where you can run and debug it.

Apryse Docs Image

Your default app is created so you can run and debug your project.

3. Integrate the Apryse Server SDK into your application

  1. In Visual Studio, from the Tools menu, select NuGet Package Manager, then select Manage NuGet Packages for Solution.
Apryse Docs Image

Access the NuGet Package Manager.

2. Under the Browse tab, in the Search field, enter Apryse, then click Enter. This will show you the various libraries that Apryse has published.

Apryse Docs Image

Search for the libraries that Apryse has published.

3. In the search results, select PDFTron.NET.x64.

4. In the Versions pane, select Project and GetStarted_DotNET, then click Install.

Apryse Docs Image

Select the GetStarted_DotNET project to install.

5. In the Preview Changes dialog, click Apply to add it to your project.

Apryse Docs Image

When you click Apply the changes will be made to your solution.

6. Once it’s been added, in the Output pane, you will see that it’s Finished:

Apryse Docs Image

When you see Finished in the Output pane, the solution has been updated.

4. Initialize PDFNet

  1. Copy the following code, click on the Program.cs tab under the Main Visual Studio toolbar, and paste it in Line 1 of the Program.cs file:

C#

1using System;
2// Most commonly used namespaces for Apryse SDK.
3using pdftron;
4using pdftron.Common;
5using pdftron.PDF;
6using pdftron.SDF;
7namespace myApp
8{
9 class Program
10 {
11 static void Main(string[] args)
12 {
13 Console.WriteLine("Hello World!");
14 // Initialize PDFNet before using any Apryse related
15 // classes and methods (some exceptions can be found in API)
16 PDFNet.Initialize("YOUR_LICENSE_KEY");
17 // Using PDFNet related classes and methods, must
18 // catch or throw PDFNetException
19 try
20 {
21 using (PDFDoc doc = new PDFDoc())
22 {
23 doc.InitSecurityHandler();
24 // An example of creating a new page and adding it to
25 // doc's sequence of pages
26 Page newPg = doc.PageCreate();
27 doc.PagePushBack(newPg);
28 // Save as a linearized file which is most popular
29 // and effective format for quick PDF Viewing.
30 doc.Save("linearized_output.pdf", SDFDoc.SaveOptions.e_linearized);
31 System.Console.WriteLine("Done. Results saved in linearized_output.pdf");
32 }
33 }
34 catch (PDFNetException e)
35 {
36 System.Console.WriteLine(e.Message);
37 }
38 // Makes the program wait to terminate after user input
39 Console.ReadKey();
40 }
41 }
42}

2. 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. If you’re logged in to Apryse.com, your license key will automatically replace YOUR_PDFTRON_LICENSE_KEY in the code below.

Apryse Docs Image

Add your license key.

3. Click GetStarted_DotNET on the Visual Studio Main toolbar to run the code. The Windows command line will open and you will see:

Apryse Docs Image

The Windows command line opens and you see Hello World!

Once you click GetStarted_DotNET above, the code initializes the Apryse Server SDK in the .NET environment, creates the sample PDF document, and performs basic PDF operations such as reading document information, extracting text, and saving output. The code also demonstrates essential API usage for tasks like loading documents and manipulating pages.

4. Exit out of the command line and navigate in File Explorer to the Windows folder where the PDF file has been saved (this is the location you specified in step 2 of the 1. Create a new project section above).

Apryse Docs Image

Navigate to the location of the PDF file you created.

5. Open the linearized_output.pdf which 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 .NET PDF Library into your application, you can try out 50+ samples depending on your needs.

Apryse Docs Image

Based on your needs, you can browse over 50 samples to try.

6. To try additional samples, go to section 2. Run a sample > step 3 above 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