Skip to main content

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.

tip

Try the Pdftools SDK without a license key.

Prerequisites

The Pdftools SDK for .NET requires .NET and .NET Core 2.0 or higher, or .NET Framework 4.6.1 or higher.

Get 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

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

info

This documentation uses Visual Studio 2022.

  1. Clone the sdk-examples-csharp repository:

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

    sdk-examples-csharp/Pdf2ImgSimple/PdfToolsPdf2ImgSimple.csproj
  3. Click Build -> Build Solution to compile the project.

  4. Within the code example, open your terminal.

  5. The code example contains a PDF file PdfPrimerWhitePaper.pdf. To render it in multi-page TIFF image format, run:

    ./bin/Debug/net6.0/PdfToolsPdf2ImgSimple PdfPrimerWhitepaper.pdf tiff_output.tiff

The code example takes:

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

Compare the command syntax with a placeholder to the previous procedure:

./bin/Debug/net6.0/PdfToolsPdf2ImgSimple INPUT_FILE OUTPUT_FILE

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.

tip

You can apply a similar procedure 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.

Add the SDK to your project

info

This documentation uses 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 SDK.
  4. Select the NuGet package named PdfTools 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.

Optional: Initialize the SDK

Learn how to remove watermarked output of the Pdftools SDK using a valid license key.

tip

Initialization removes watermarks from output files and readies the SDK for production. Without a license key, output files carry a watermark.

Getting a license key

Contact the Pdftools sales team through the Contact page to get a full license. For more information, review the Pdftools SDK license management.

To remove watermarks, 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 Pdftools SDK method call:

    Sdk.Initialize("YOUR_LICENSE_KEY");

    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. Clone the sdk-examples-csharp repository and navigate to a sample directory. For example, sdk-examples-csharp/Pdf2ImgSimple.
  2. Open Program.cs and find the commented-out Sdk.Initialize call. For example, the Pdf2ImgSimple C# sample includes it in Program.cs.
  3. Uncomment the call and replace the "insert-license-key-here" 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.
  • If you need to configure a proxy, review Configure proxy documentation section.