Get started with .NET
This guide walks you through the steps to use a sample project, and then explains how to integrate the Toolbox add-on into your application with .NET.
Request trial or full license
Unlike the Pdftools SDK or the Pdftools SDK Shell Tool, the Toolbox add-on requires a license key for both evaluation and full use. To request a license key, follow these steps:
- Reach out to 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 Toolbox add-on using a C# sample project and extract all images and image masks from a PDF document.
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:
- Command line
- Visual Studio
-
Download a sample project, and then unzip the file.
-
Copy your license key. For more information, review Find the license key.
-
In the
Program.cs
file, replace the string"insert-license-key-here"
with your license key:Sdk.Initialize("insert-license-key-here", null);
Use the license key in the same format as you copied it. Include the less-than (
<
) and greater-than (>
) signs. -
In the command line, navigate to the root directory of the unzipped sample project.
-
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:dotnet run --framework net6.0 --project ToolboxImageExtraction.csproj ImageCollection.pdf /tmp/images
The code sample 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:
dotnet run --framework net6.0 --project ToolboxImageExtraction.csproj INPUT_FILE OUTPUT_DIRECTORY
This documentation uses Visual Studio 2022.
- Download a sample project, and then unzip the file.
- In the sample folder, double click
ToolboxImageExtraction.csproj
- In the
Program.cs
file, replace the string"insert-license-key-here"
with your license key:
Sdk.Initialize("insert-license-key-here", null);
-
Click Build -> Build Solution to compile the project.
-
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 sample 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
You can apply a similar procedure as described in this tutorial for other code samples. 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
- Command line
- Visual Studio
In the project directory, run the following command:
dotnet add package PdfTools.Toolbox
Optional: If you want to use a specific version of the Pdftools SDK, run the following command:
dotnet add package PdfTools.Toolbox --version <VERSION>
The integration section describes the process using Visual Studio 2022 on Windows.
- Open your solution in Visual Studio.
- Click Tools > Nuget Package Manager > Manage NuGet Packages for Solution....
- Click the Search tab and search for
PdfTools.Toolbox
. - Select the NuGet package named
PdfTools.Toolbox by PDF Tools AG
, select your Project, and then click Install. - Click OK to allow the changes, and then review and Accept the license agreement.
Initialize the SDK
The Toolbox add-on requires a license key even in a trial version (unlike the Pdftools SDK which you can try without a license key). To initialize the Toolbox add-on with your license key, follow these steps:
-
Copy your license key. For more information, review Find the license key.
-
Find the following method, and then replace the
insert-license-key-here
with the value of your license key:Sdk.Initialize("insert-license-key-here", null);
Use the license key in the same format as you copied it. Include the less-than (
<
) and greater-than (>
) signs.
Without a valid license key the Toolbox add-on returns an error. Get in touch with the Pdftools sales team through the Contact page to get a full license.
Implement your use case
- Find more use cases and sample projects at the Toolbox add-on Code samples page.
- For more technical information about the Toolbox add-on for .NET, consult the .NET technical notes.