Get started with .NET
This guide walks you through the steps to use a code example, and then explains how to integrate the Pdftools SDK into your application with .NET.
Prerequisites
The Pdftools SDK 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 Pdftools SDK using a C# code example. The Pdf2ImgSimple example converts a PDF file to an image. Use similar steps to run any other code example from the sdk-examples-csharp repository.
Compile and run the sample
- Visual Studio
- Command line
This sample describes the process using Visual Studio 2022.
-
Clone the sdk-examples-csharp repository:
git clone https://github.com/pdf-tools/sdk-examples-csharp.git -
Open the project in Visual Studio:
sdk-examples-csharp/Pdf2ImgSimple/PdfToolsPdf2ImgSimple.csproj -
Click Build -> Build Solution to compile the project.
-
Process a file:
PdfToolsPdf2ImgSimple <inputPath> <outputPath>For example, to render the sample PDF file
PdfPrimerWhitePaper.pdfto a multi-page TIFF image format, run:PdfToolsPdf2ImgSimple PdfPrimerWhitepaper.pdf tiff_output.tiff
-
Clone the sdk-examples-csharp repository:
git clone https://github.com/pdf-tools/sdk-examples-csharp.git -
In the example folder, run the following command providing
inputPathfor the input PDF file andoutputPathpath for the output image file:dotnet run --framework net6.0 --project PdfToolsPdf2ImgSimple.csproj <inputPath> <outputPath>For example, to render the sample PDF file
PdfPrimerWhitePaper.pdfto a multi-page TIFF image format, run:dotnet run --framework net6.0 --project PdfToolsPdf2ImgSimple.csproj PdfPrimerWhitepaper.pdf tiff_output.tiff
The sample runs without a license key, and the output carries a watermark. To remove the watermark, open Program.cs and uncomment the Sdk.Initialize method call in Main(). Replace the "insert-license-key-here" placeholder with your license key. Include the less-than (<) and greater-than (>) signs.
You can apply a similar procedure as described in this tutorial for other code examples. For more information, see Code samples page.
Integrate the SDK into your application
Integrate and initialize the Pdftools SDK into your application by following the instructions in the next sections.
Add the SDK to your project
- Visual Studio
- Command line
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 SDK. - Select the NuGet package named
PdfTools 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.
In the project directory, run the following command:
dotnet add package PdfTools
Optional: If you want to use a specific version of the Pdftools SDK, run the following command:
dotnet add package PdfTools --version <VERSION>
Optional: Initialize the SDK
The Pdftools SDK runs without an explicit Sdk.Initialize call by auto-activating an internal test license that watermarks the output. Call Sdk.Initialize with your license key to remove the watermark.
Contact the Pdftools sales team through the Contact page to get a full license.
Call Sdk.Initialize once at application startup, before any other Pdftools SDK method call:
Sdk.Initialize("YOUR_LICENSE_KEY");
Use the license key in the same format you copied it. Include the less-than (<) and greater-than (>) signs.
For a working reference, see the Sdk.Initialize method in the Pdf2ImgSimple C# sample. In SDK samples the call is commented out by default with an "insert-license-key-here" placeholder; uncomment it and replace the placeholder with your license key.
Implement your use case
- Find more use cases and code examples on the Code samples page.
- For more technical information about the Pdftools SDK for .NET, consult the .NET technical notes.