PdfGate.net 0.1.0

dotnet add package PdfGate.net --version 0.1.0
                    
NuGet\Install-Package PdfGate.net -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PdfGate.net" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PdfGate.net" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="PdfGate.net" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PdfGate.net --version 0.1.0
                    
#r "nuget: PdfGate.net, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PdfGate.net@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PdfGate.net&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=PdfGate.net&version=0.1.0
                    
Install as a Cake Tool

PdfGate.net

NuGet

The official PDFGate official .NET SDK supporting .NET Standard 2.0+.

Installation

Using the .NET Core command-line interface (CLI) tools:

dotnet add package PdfGate.net

Using the NuGet Command Line Interface (CLI):

nuget install PdfGate.net

Using the Package Manager Console:

Install-Package PdfGate.net

From within Visual Studio:

  1. Open the Solution Explorer.
  2. Right-click on a project within your solution.
  3. Click on Manage NuGet Packages...
  4. Click on the Browse tab and search for "PdfGate.net".
  5. Click on the PdfGate.net package, select the appropriate version in the right-tab and click Install.

Requirements

We currently support .NET Standard 2.0+, which means the minimum requirements are:

  • .NET Framework 4.6.1+
  • .NET Core 2.0+ (includes 3.1, 5, 6, 7, 8)
  • Mono 5.4+
  • Xamarin (iOS/Android)
  • Universal Windows Platform (UWP) 10.0.16299+

Documentation

You can find the full HTTP API documentation here and there's code documentation in the SDK.

Usage

First, you will always need a client to interact with the API. The only thing you need to create a client is your API key for authentication (more details about authentication here):

using System.Text.Json;
using PdfGate.@net;
using PdfGate.@net.Models;

internal static class Program
{
    private static void Main()
    {
        var apiKey = "test_your_api_key_here";

        using var client = new PdfGate(apiKey);

        // client is ready to call API methods, e.g. client.GeneratePdf(...)
    }
}

Then, the two main usage patterns are:

PDF Generation

Generate a new PDF from an HTML:

var request = new GeneratePdfRequest 
{
    Html = 
        "<html><body><h1>Acceptance Test</h1><p>Generated by SDK acceptance test.</p></body></html>"
};

var generatedDoc = await client.GeneratePdfAsync(request, CancellationToken.None);

or a URL:

GeneratePdfRequest request = new GeneratePdfRequest 
{
    Url = 
        "https://example.com/pdf-gate.pdf"
};

var generatedDoc = await client.GeneratePdfAsync(request, CancellationToken.None);

and then download it with GetFile:

var getFileRequest = new GetFileRequest { DocumentId = generatedDoc.Id };

Stream fileResponse = await client.GetFileAsync(getFileRequest, CancellationToken.None);

PDF Transformation

First, you will need to upload the file you want to transform. You can do this by generating a file from HTML or an URL as shown above, or you can upload a PDF file directly via UploadFileAsync:

using Stream fileToUpload = File.OpenRead("input.pdf");
var request = new UploadFileRequest { Content = fileToUpload };

PdfGateDocumentResponse uploadedResponse = await client.UploadFileAsync(request, CancellationToken.None);

Once you have a Document ID, you can transform it with any of the following operations:

Flatten PDF

var flattenRequest = new FlattenPdfRequest
{
    DocumentId = uploadedResponse.Id
};

PdfGateDocumentResponse flattenedDoc = await client.FlattenPdfAsync(
    flattenRequest,
    CancellationToken.None);

Watermark PDF

var watermarkRequest = new WatermarkPdfRequest
{
    DocumentId = uploadedResponse.Id,
    Type = WatermarkPdfType.Text,
    Text = "CONFIDENTIAL",
    Font = WatermarkPdfFont.HelveticaBold,
    FontColor = "#9C32A8",
    FontSize = 30,
    Rotate = 30,
    Opacity = 0.2
};

PdfGateDocumentResponse watermarkedDoc = await client.WatermarkPdfAsync(
    watermarkRequest,
    CancellationToken.None);

Protect a PDF

var protectRequest = new ProtectPdfRequest
{
    DocumentId = uploadedResponse.Id,
    Algorithm = ProtectPdfEncryptionAlgorithm.Aes256,
    UserPassword = "user-password",
    OwnerPassword = "owner-password",
    DisablePrint = true,
    DisableCopy = true,
    DisableEditing = true
};

PdfGateDocumentResponse protectedDoc = await client.ProtectPdfAsync(
    protectRequest,
    CancellationToken.None);

Compress a PDF

var compressRequest = new CompressPdfRequest
{
    DocumentId = uploadedResponse.Id,
    Linearize = true
};

PdfGateDocumentResponse compressedDoc = await client.CompressPdfAsync(
    compressRequest,
    CancellationToken.None);

All of these operations will return a new Document ID that points to the document that resulted from this transformation. You can then download it with GetFileAsync:

var getFileRequest = new GetFileRequest { DocumentId = transformedDoc.Id };

Stream fileResponse = await client.GetFileAsync(getFileRequest, CancellationToken.None);

PDF Data Extraction

The ExtractPdfFormData method lets you read data from a fillable PDF. It extracts all form fields in the document along with their current values and returns them as a JSON object.

var extractRequest = new ExtractPdfFormDataRequest
{
    DocumentId = uploadedResponse.Id
};

JsonElement formData = await client.ExtractPdfFormDataAsync(
    extractRequest,
    CancellationToken.None);

PDF Sharing

In the case that you don't need the actual resulting PDF file, you just need to a way for other clients or users to access it, you can do so by requesting on any method that the response includes a pre-signed URL:

var generateRequest = new GeneratePdfRequest
{
    Url = "https://example.com/invoice",
    PreSignedUrlExpiresIn = 3600
};

PdfGateDocumentResponse generatedWithUrl = await client.GeneratePdfAsync(
    generateRequest,
    CancellationToken.None);

string? shareableFileUrl = generatedWithUrl.FileUrl;

You can also request a refreshed pre-signed URL for an existing document:

var getDocumentRequest = new GetDocumentRequest
{
    DocumentId = generatedWithUrl.Id,
    PreSignedUrlExpiresIn = 3600
};

PdfGateDocumentResponse documentWithRefreshedUrl = await client.GetDocumentAsync(
    getDocumentRequest,
    CancellationToken.None);

Development

Prerequisites

  • .NET SDK 8.0+ (used by the test projects and CI)

Restore dependencies

dotnet restore PdfGate.sln

Build

dotnet build PdfGate.sln

Format

dotnet format PdfGate.sln

Run tests

Run all tests:

dotnet test PdfGate.sln

Run only unit tests:

dotnet test tests/PdfGate.net.UnitTests/PdfGate.net.UnitTests.csproj

Run acceptance tests (single-threaded, no node reuse):

dotnet test tests/PdfGate.net.AcceptanceTests/PdfGate.net.AcceptanceTests.csproj /m:1 /nr:false

Acceptance test setup

Acceptance tests call the real PDFGate API and require an API key in PDFGATE_API_KEY.

export PDFGATE_API_KEY="test_your_api_key_here"

If PDFGATE_API_KEY is not set, acceptance tests are skipped.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 81 3/25/2026