For the complete documentation index, see llms.txt. This page is also available as Markdown.

Build a .NET Framework PDF library app with Apryse Server SDK

This guide shows how to build a simple .NET Framework PDF application on Windows 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.

Prerequisites

  • Install Visual Studio to build, test, and deploy applications. This guide uses Visual Studio 2022. The minimum supported version is Visual Studio 2019.

  • Install the .NET desktop development workload and the .NET Framework development tools for your version of .NET Framework. You can install these components through the Visual Studio Installer. For more, see Microsoft's documentation.

  • Get your Apryse trial key.

spinner

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.

1. Set up your project

In Visual Studio, begin by setting up your project and preparing your workspace for the application.

  1. Open Visual Studio and go to File > New > Project.

  2. Select C# Console App (.NET Framework) or VB Console App (.NET Framework), 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.

  1. In the Framework dropdown, select the .NET Framework version. For example, .NET Framework 4.8.1.

  2. Click Create to launch the new app where you can run and debug your project.

2. Add the Apryse SDK

Next, add the Apryse SDK to your .NET Framework application and configure your project to work with PDF documents. You can install the SDK using the NuGet Package Manager (recommended) or manually download and reference the SDK files.

  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 PDFNet. For more package information, see NuGet.

  4. In the Manage Packages for Solution dialog, select the project, then click Install.

Visual Studio Manage NuGet Packages window showing the PDFTron.NetFramework.x64 package with version options and an Install button.
Manage NuGet Packages dialog in Visual Studio with PDFTron.NetFramework.x64 installation options.
  1. In the Preview Changes modal, click Apply to install the package in your project.

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

  1. In Solution Explorer, open the source file for your project (Program.cs for C# or Module1.vb for VB). Replace the file contents with the following code, update your license key, and save the file:

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

  • Load the appropriate PDFNet native libraries for the application's architecture.

  • Initialize the Apryse SDK with a license key.

  • Create a new PDF document, add a blank page, and save it as a linearized PDF.

  • Handle SDK exceptions and automatically release resources.

  • Terminate the Apryse SDK when processing is complete.

About PDFNetLoader

The NuGet package uses PDFNetLoader to support both 32-bit and 64-bit processes from a single build. It deploys both the x86 and x64 versions of PDFNet.dll and automatically loads the appropriate version at runtime based on the application's architecture.

For most applications, no additional configuration is required. This approach works well with the Any CPU platform target commonly used by .NET Framework projects.

If your application targets a specific architecture, such as x64 or x86, you may be able to deploy only the corresponding version of PDFNet.dll and remove PDFNetLoader. However, this requires additional changes to the project's references and deployment configuration and is not covered in this guide.

In summary, PDFNetLoader is primarily intended for Any CPU applications that need to support both 32-bit and 64-bit processes from the same build.

For more, see our blog post about PDFNetLoader.

  1. Download and unzip the PDFNetDotNet4.zip file.

  2. Copy the extracted /PDFNetDotNet4/Lib folder.

  3. Go to your project's folder. By default, the path is similar to:

  1. Paste the /PDFNetDotNet4/Lib folder you copied into the project folder that contains your .csproj or .vbproj file. The resulting structure looks similar to:

  1. In the Solution Explorer in Visual Studio, right-click References > Add Reference.

  2. In the Reference Manager modal, click Browse.

  3. Add the copied Lib\PDFNetLoader.dll folder from the following location to the references, and click OK:

  1. Add the following x86 version of PDFNet.dll as a reference, then click OK:

Info

When used with PDFNetLoader.dll, this configuration allows an Any CPU application to run on both 32-bit and 64-bit Windows systems by loading the appropriate Apryse libraries at runtime.

  1. In the Solution Explorer, select References > PDFNet, and set its Copy Local property to False.

  2. Click to open the App.config file from the Solution Explorer, add the following loadFromRemoteSources property, and save:

  1. Right-click your project and select Properties.

From the project properties, open the Build Events tab. Add the following command to the Post-build event field:

From the project properties, open the Compile tab, then scroll to the Build Events button. Add the following command to the Post-build event command line field, then click OK:

Info

This post-build event copies the Apryse native libraries from the project's Lib\PDFNet folder to the application's output directory (bin\Debug or bin\Release) so that PDFNetLoader can load the appropriate 32-bit or 64-bit binaries at runtime.

  1. In Solution Explorer, open the source file for your project (Program.cs for C# or Module1.vb for VB). Replace the file contents with the following code, update your license key, and save:

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

  • Load the correct PDFNet native libraries based on the application's architecture.

  • Initialize the Apryse SDK with a license key.

  • Create a new PDF document, add a blank page, and save it as a linearized PDF.

  • Handle SDK exceptions and automatically release resources.

  • Terminate the Apryse SDK when processing is complete.

About PDFNetLoader

The steps in this section use PDFNetLoader to support both 32-bit and 64-bit processes from a single build. This approach deploys both the x86 and x64 versions of PDFNet.dll and automatically loads the appropriate version at runtime based on the application's architecture.

For most applications, this level of flexibility is not required. If your application targets a specific architecture, such as x64 or x86, reference the corresponding version of PDFNet.dll directly, set Copy Local to True, update the project's Platform target in Visual Studio, and remove both PDFNetLoader.dll and the PDFNetLoader initialization code.

If your application must support both 32-bit and 64-bit environments, you can continue using PDFNetLoader. Another option is to deploy only the appropriate version of PDFNet.dll based on the target system. For example, a 64-bit installation can deploy the x64 version of PDFNet.dll, while a 32-bit installation can deploy the x86 version. Since only one version is installed, PDFNetLoader is not required.

In summary, PDFNetLoader is primarily intended for Any CPU applications that need to support both 32-bit and 64-bit processes from the same build. Applications that target a specific architecture can usually reference the appropriate version of PDFNet.dll directly.

For more, see our blog post about PDFNetLoader.

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:

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

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

Next steps

GuidesAPI docsSamples

Last updated

Was this helpful?