.NET Core PDF library integration

Welcome to Apryse. .NET Core for the Apryse SDK is cross-platform and supported on Windows, Linux and macOS. To get started, choose your preferred platform from the tabs below.

Windows .NET Core PDF library integration

This guide will help you run Apryse samples and integrate a free trial of the Apryse SDK into .NET Core applications on Windows. Your free trial includes unlimited trial usage and support from solution engineers.

  • Visual Studio Make sure that the .NET Core cross-platform development workload and MSBUILD are part of your installation.This guide will use Visual Studio 2017. If you would like to use the NuGet integration for Windows x64 please make sure you have Visual Studio 2017 or later.Note: Apryse SDK is multi-targeting. Target Frameworks : .NET Core 2.1+, .NET Standard 2.1, .NET 5, .NET 6, .NET 7, .NET 8.
  • Apryse's .NET Core PDF library for Windows:
    Download the SDK
    download Windows 64-bit Apryse SDK
    Download the SDK
    download Windows 32-bit Apryse SDK

Run Apryse SDK in production

A commercial license key is required for use in a production environment. Please fill out our licensing form if you do not have a valid license key.

Keep your commercial license key confidential.

License keys are uniquely generated. Please make sure that it is not publicly available (e.g. in your public GitHub).

Initial setup

1. Extract the folder from the .zip file.

This article uses PDFNET_BASE as the path into the folder that you extracted.

Text

1PDFNET_BASE = path/to/extraction/folder/PDFNetC(64)/

2. Get your Apryse trial key.

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

Navigate to the location of extracted contents. Find and enter the Samples folder (PDFNET_BASE/Samples). Here you can find sample code for a large number of features supported by the Apryse SDK.

Run a specific sample

1. Find the sample you want to run and navigate into the CS folder inside.

2. Open a Command Prompt here and run:

Text

1dotnet run

Alternatively, you can open the project in Visual Studio, Set as Startup Project and run it (F5).

Run all samples

1. Download the runall_dotnet.bat zip and extract the file into the PDFNET_BASE/Samples folder.

2. Double click the file in this location to run all the .NET Core samples.

Integrate into your application

You can follow a manual or nuget integration as described below.

Manually

This section will help you build the "Apryse Hello World" application. It is easy to integrate the rest of Apryse SDK if you are able to open, save and close a PDFDoc.

1. Open a new instance of Visual Studio 2017 and create a new .NET Core console application project (File > New > Project... ). You can find this under the Visual C# menu.

Apryse Docs Image

Click on OK and allow the IDE to create the project.

2. Find the Solution Explorer on the right side of the screen. Select the project and press Alt + Enter. This will open the properties tab.

Alternatively, you can right click on the project and find the properties option.

Select .NET Core 2.1 (or above) as the target framework for your application.

Apryse Docs Image

If you are using a Windows x64 machine for your .NET Core development, you can use NuGet package manager to get the Apryse SDK. Otherwise, please integrate the SDK manually.

3. Right click on project Dependencies and click on Add Reference. This will open the Reference Manager dialog. Click on the Browse... option at the bottom of the dialog. Navigate to PDFNET_BASE/Lib and select PDFNetDotNetCore.dll and click Add.

Apryse Docs Image

Click OK on the Reference Manager and continue.

4. In the Solution Explorer, select the project and press Shift + Alt + A. With this you can Add an Existing Item.

Alternatively, you can right click on the project and find the Add an existing item... option under the Add submenu.

Once again, navigate to PDFNET_BASE/Lib. Choose the file type as All Files (*.*) and select PDFNetC.dll. Click on Add.

Apryse Docs Image

5. Select PDFNetC.dll in the solution explorer. A properties window should appear below. In it, change the Build Action setting to Content and the Copy to Output Directory setting to Copy always. To avoid errors, use the drop-down menus available for those fields.

Apryse Docs Image

NuGet using Visual Studio

This section will go through the nuget integration steps.

1. Perform the first 2 steps of integrating manually.

2. Right click on project Dependencies and click on Manage NuGet Packages.... This will open the NuGet Package Manager.

3. Click on the Browse tab near the top of the package manager. In the search bar enter:

Text

1PDFTron.NET.x64

4. Select the PDFTron.NET.x64 package by Apryse Systems Inc. and click on the Install button in the panel with the package information. If you're prompted or an external dialog is opened for confirmation, click on Ok.

Apryse Docs Image

5. Get your Apryse trial key.

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.

The Code

Replace the contents of Program.cs with:

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_APRYSE_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}

Run the program using the Local Windows Debugger. The program will give the following output in the console:

Apryse Docs Image

You should see an output file produced at the location of your project. If you used .NET Core 2.1, then by default it will be in the following folder:

Text

1C:\Users\User_Name\source\repos\myApp\myApp\bin\Debug\netcoreapp2.1

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales