LogoDOCS
OverviewAuthenticationRate LimitsErrors
Logo
Sign in →

C# SDK

The .NET SDK provides a client for integrating PDFGate API endpoints into your C# applications.

Source code: github.com/pdfgate/pdfgate-sdk-dotnet
Package: nuget.org/packages/PdfGate.net

Installation

Install the package with the .NET CLI, the NuGet CLI, or the Package Manager Console, then initialize the client with your API key.

.NET CLI
1dotnet add package PdfGate.net
NuGet CLI
1nuget install PdfGate.net
Package Manager Console
1Install-Package PdfGate.net

Create a client

The only requirement to create the client is your API key. Once initialized, the client is ready to call any of the available methods.

1using System.Text.Json;2using PdfGate.@net;3using [email protected];45internal static class Program6{7    private static void Main()8    {9        var apiKey = "test_your_api_key_here";1011        using var client = new PdfGate(apiKey);1213        // client is ready to call API methods, e.g. client.GeneratePdf(...)14    }15}

Generate and download a PDF

A common workflow is to generate a PDF first, then download the resulting file stream using the returned document id.

1var request = new GeneratePdfRequest2{3    Html =4        "<html><body><h1>Hello from PDFGate</h1><p>Generated by SDK.</p></body></html>"5};67var generatedDoc = await client.GeneratePdfAsync(request, CancellationToken.None);89var getFileRequest = new GetFileRequest { DocumentId = generatedDoc.Id };1011Stream fileResponse = await client.GetFileAsync(getFileRequest, CancellationToken.None);

Core methods

MethodPurpose
GeneratePdfAsyncGenerate a PDF from HTML or a URL.
GetDocumentAsyncRetrieve document metadata and refreshed pre-signed URLs.
GetFileAsyncDownload the stored PDF stream for a document id.
UploadFileAsyncUpload a PDF file for later transformations.
FlattenPdfAsyncFlatten fillable form fields into a non-editable PDF.
WatermarkPdfAsyncApply text or image watermarks to a document.
ProtectPdfAsyncEncrypt a PDF and apply restrictions such as print or copy limits.
CompressPdfAsyncCompress a PDF and return the resulting document record.
ExtractPdfFormDataAsyncRead field values from a fillable PDF.

Related documentation

Use the SDK together with the main API documentation for request parameters, endpoint behavior, and workflow guides such as webhooks and PDF form fields.