Get started with the Apryse Server SDK .NET PDF library integration

This guide shows how to build a simple .NET PDF application that uses the Apryse Server SDK and PDFNet library to generate a PDF programmatically. You’ll set up a minimal project, install the SDK, and add the required code to create a blank PDF document. This example provides a practical foundation for building more advanced document‑generation workflows.

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

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

2. Add the Apryse SDK

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:

  • Import the required Apryse PDFNet namespaces.
  • Define a console application entry point using Main.
  • Log a startup message to the console.
  • Initialize the Apryse SDK with a license key.
  • Create a new PDF document, add a blank page, and save it as a linearized PDF.
  • Automatically release document resources with the using statement.

3. Verify your output

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

Get started video

Get started with the Apryse Server SDK and .NET on Windows by watching this 4-minute video.

Get started video for Apryse Server SDK on the Windows platform

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