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

This guide walks you through steps to work through samples we give you, create a project, and integrate the Apryse Server SDK free trial into your project. We’ll use a .NET Core project as our example project throughout this guide. By the end, you’ll have run through at least one sample, created a project, and built an "Apryse Hello World" within your application.

Get started video

Get started with the Apryse Server SDK on the Windows platform via the following video. If you wish, you may skip this section and follow the steps below to get started.

Get started video for Apryse Server SDK on the Windows platform

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

Windows .NET PDF Library integration

You'll get started with our samples to see the output you can create when you integrate the Apryse Server SDK into your application. You'll also create a project and integrate the Server SDK into your application, using the Windows platform.

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. Please contact sales by filling out our licensing form if you want to purchase a commercial 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).

1. Run a sample

First, you'll download and run the OfficeToPDFTest sample which allows you to explore and validate the conversion features offered by the SDK. By running the sample, you can quickly:

  • Verify the capabilities.
  • Understand how to interact with the MS Office to PDF Conversion API.
  • Use it as a reference for integrating similar functionality into your own application.
  1. Download the PDFNetC64.zip file.
  2. Extract the PDFNetC64.zip file to the following location (replace YourName with your user name) or another location, if you prefer: C:\Users\YourName\PDFNET_BASE\PDFNetC64\Samples\ 
    For this guide’s instructions, we used the location above.
  3. Open the Windows command line and navigate to the CS as follows, replacing YourName with your user name, then press Enter:

shell

1cd C:\Users\<YourName>\PDFNET_BASE\PDFNetC64\Samples\OfficeToPDFTest\CS

4. From the project directory, on the command line, enter the following, then press Enter.

shell

1dotnet run

When you run the dotnet run command, the sample code loads an Office document, converts the Office document to PDF, saves the resulting PDF, and outputs status messages to the console. For more details, you can look at additional OfficeToPDF sample code and the Convert MS Office (Word, Excel, PowerPoint) to PDF overview.

5. Go to your Windows file explorer and navigate to: C:\Users\YourName\PDFNET_BASE\PDFNetC64\Samples\TestFiles\Output. You will see three output PDF files (Fisherman.pdf, the_rime_of_the_ancient_mariner.pdf, and the factsheet_Arabic.pdf):

Apryse Docs Image

Go to the Windows file explorer and navigate to the new PDF files you just converted.

6. Open the PDF files to see the converted output. You have successfully run the OfficeToPDFTest conversion sample!

Apryse Docs Image

Open the PDF files to see the converted output.

2. Create your own new project

  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("demo:1760388909312:60233c900300000000889ef86a08c71d995b0f65b89886183220e5b61e");
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_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_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 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