Some test text!

Search
Hamburger Icon

Core / Guides / .NET Core

.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

Linux

macOS

Windows .NET Core PDF library integration

.NET Core

Azure Functions

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.

Prerequisites

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

PDFNET_BASE = path/to/extraction/folder/PDFNetC(64)/
  1. Get your Apryse trial 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:

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

    Start new project

    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.

    Select framework

    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.

    Add .NET Core PDFNet dll

    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.

    Add PDFNetC.dll reference

  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.

    dll Settings

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:

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

    Add .NET Core Windows x64 NuGet Package

  5. Get your Apryse trial 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:

using System;

// Most commonly used namespaces for Apryse SDK.
using pdftron;
using pdftron.Common;
using pdftron.PDF;
using pdftron.SDF;

namespace myApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            // Initialize PDFNet before using any Apryse related
            // classes and methods (some exceptions can be found in API)
            PDFNet.Initialize("YOUR_APRYSE_LICENSE_KEY");

            // Using PDFNet related classes and methods, must
            // catch or throw PDFNetException
            try
            {
                using (PDFDoc doc = new PDFDoc())
                {
                    doc.InitSecurityHandler();

                    // An example of creating a new page and adding it to
                    // doc's sequence of pages
                    Page newPg = doc.PageCreate();
                    doc.PagePushBack(newPg);


                    // Save as a linearized file which is most popular
                    // and effective format for quick PDF Viewing.
                    doc.Save("linearized_output.pdf", SDFDoc.SaveOptions.e_linearized);

                    System.Console.WriteLine("Done. Results saved in linearized_output.pdf");
                }
            }
            catch (PDFNetException e)
            {
                System.Console.WriteLine(e.Message);
            }

            // Makes the program wait to terminate after user input
            Console.ReadKey();
        }
    }
}

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

Output

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:

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

Next step

Guides API docsSamples

Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales