Skip to main content
Version: Version 1.5

Get started with .NET

This guide walks you through the steps to use a code example, and then explains how to integrate the Toolbox add-on into your application with .NET.

Request trial or full license

The Toolbox add-on requires a license key for both evaluation and full use. To request a license key, follow these steps:

  1. Contact the sales team through the Contact page and mark the Toolbox add-on as the product of your interest for a trial license.

If you already have a license key and you need to copy it, review Find the license key.

Prerequisites

The Toolbox add-on for .NET requires .NET and .NET Core 2.0 or higher, or .NET Framework 4.6.1 or higher.

Getting started with a sample project

Learn how to use the Toolbox add-on using a C# code example. The ImageExtraction example extracts all images and image masks from a PDF document. Use similar steps to run any other code example from the toolbox-examples-csharp repository.

Compile and run the sample

Switch between the following tabs to display steps for the command line interface or for the Visual Studio. To compile and run the sample, follow these steps:

info

This documentation uses Visual Studio 2022.

  1. Clone the toolbox-examples-csharp repository:

    git clone https://github.com/pdf-tools/toolbox-examples-csharp.git
  2. Open the project in Visual Studio:

    toolbox-examples-csharp/ImageExtraction/ToolboxImageExtraction.csproj
  3. In the Program.cs file, replace the string "YOUR_LICENSE_KEY" with your license key:

Sdk.Initialize("YOUR_LICENSE_KEY", null);
  1. Click Build -> Build Solution to compile the project.

  2. To extract all images and image masks from the sample PDF file ImageCollection.pdf to the output directory /tmp/images, run the compiled sample application:

    ToolboxImageExtraction ImageCollection.pdf /tmp/images

The code example takes:

  • The input and output files represented as a file name, a file path with the file name, or the output directory.
  • Both file paths (input and output) can be relative or absolute.

Review the following snippet with a placeholder and compare it to the last step of the previous procedure:

ToolboxImageExtraction INPUT_FILE OUTPUT_DIRECTORY
tip

You can apply a similar procedure described in this tutorial for other code examples. For more information, see Code samples page.

Integrate the Toolbox add-on into your application

Integrate and initialize the Toolbox add-on into your application by following the instructions in the next sections.

Add the Toolbox add-on to your project

info

The integration section describes the process using Visual Studio 2022 on Windows.

  1. Open your solution in Visual Studio.
  2. Click Tools > Nuget Package Manager > Manage NuGet Packages for Solution….
  3. Click the Search tab and search for PdfTools.Toolbox.
  4. Select the NuGet package named PdfTools.Toolbox by PDF Tools AG, select your Project, and then click Install.
  5. Click OK to allow the changes, and then review and Accept the license agreement.

Initialize the SDK

The Toolbox add-on always requires a license key to operate (unlike the Pdftools SDK). Without a valid license, every Toolbox add-on function call fails with LicenseError: No license key was set.

Getting a license key

Contact the Pdftools sales team through the Contact page to get a full license.

To initialize the Toolbox add-on with your license key, follow these steps:

  1. Find your license key. For more information, review Find the license key.

  2. Call Sdk.Initialize once at application startup, before any other Toolbox add-on method call:

    Sdk.Initialize("YOUR_LICENSE_KEY", null);

    Replace YOUR_LICENSE_KEY with your license key. Use the license key in the same format you copied it. Include the less-than (<) and greater-than (>) signs.

To get a working reference with the Sdk.Initialize method, follow these steps:

  1. On the Code samples page, clone a sample repository. For example, clone toolbox-examples-csharp and navigate to toolbox-examples-csharp/ImageExtraction.
  2. Find the Sdk.Initialize method in the C# file of the sample. For example: Extract all images and image masks from a PDF (C, C#, Java, Python) includes the Sdk.Initialize method in the Program.cs file.
  3. Replace the "insert-license-key-here" placeholder in the sample with your license key. Include the less-than (<) and greater-than (>) signs.

Implement your use case

  • Find more use cases and code examples on the Toolbox add-on Code samples page.
  • For more technical information about the Toolbox add-on for .NET, consult the .NET technical notes.