Get started with .NET
This guide walks you through the steps to use a sample project, 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# sample project and convert a PDF file to an image.
Compile and run the sample
- Visual Studio
- Command line
This sample describes the process using Visual Studio 2022.
-
Download a sample project, and then unzip the file.
-
In the sample folder, double click
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.pdf
to a multi-page TIFF image format, run:PdfToolsPdf2ImgSimple PdfPrimerWhitepaper.pdf tiff_output.tiff
-
Download a sample project, and then unzip the file.
-
In the sample folder, run the following command providing
inputPath
for the input PDF file andoutputPath
path for the output image file:dotnet run --framework net6.0 --project PdfToolsPdf2ImgSimple.csproj <inputPath> <outputPath>
For example, to render the sample PDF file
PdfPrimerWhitePaper.pdf
to a multi-page TIFF image format, run:dotnet run --framework net6.0 --project PdfToolsPdf2ImgSimple.csproj PdfPrimerWhitepaper.pdf tiff_output.tiff
You can apply a similar procedure as described in this tutorial for other code samples. 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>
Initialize the SDK
After installing the Nuget package the final step before using the SDK is to initialize the SDK with your license key. Replace the <PDFSDK,V1,include-your-key-here>
in the following method with the value of your license key:
Sdk.Initialize("<PDFSDK,V1,include-your-key-here>");
Without a valid license key the output files are watermarked. 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 Code samples page.
- For more technical information about the Pdftools SDK for .NET, consult the .NET technical notes.