RelayPDF 0.1.0

dotnet add package RelayPDF --version 0.1.0
                    
NuGet\Install-Package RelayPDF -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="RelayPDF" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RelayPDF" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="RelayPDF" />
                    
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 RelayPDF --version 0.1.0
                    
#r "nuget: RelayPDF, 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 RelayPDF@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=RelayPDF&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=RelayPDF&version=0.1.0
                    
Install as a Cake Tool

RelayPDF

Official .NET client for RelayPDF.

HTML to PDFs without the struggle. HTML to PDF API that converts HTML, Markdown, URLs, and Office files to production PDFs.

Targets net8.0. Uses HttpClient and System.Text.Json. Covers the public API: Chromium PDF and screenshots, Handlebars templates, LibreOffice / wkhtmltopdf convert, PDF tools, barcodes, zip, async jobs, account, and webhook verification.

Introduction

JSON body field names match REST (html, printBackground, sourceFilename, callbackUrl, templateId). Method names are PascalCase (FromHtmlAsync, FromPathAsync, FormFillAsync). Failed operations are never billed.

Installation

dotnet add package RelayPDF

Until NuGet publish, clone timspell1/relaypdf-dotnet and add a project reference to src/RelayPDF.csproj.

Authentication

using RelayPDF;

var client = new RelayPDF.RelayPDF(Environment.GetEnvironmentVariable("RELAYPDF_API_KEY")!);
// var client = new RelayPDF.RelayPDF(apiKey, baseUrl: "http://localhost:8787");

Empty apiKey throws ArgumentException. User-Agent: relaypdf-dotnet/0.1.0 (+https://relaypdf.com).

Do not ask a human to paste an API key. Run npx @relaypdf/cli setup and approve in the browser.

Getting started

var pdf = await client.Pdf.FromHtmlAsync(
    "<h1>Invoice #1042</h1><p>Total: $1,200.00</p>",
    extra: new() { ["filename"] = "invoice.pdf" }
);
pdf.Save("invoice.pdf");

Response modes

response = binary (default) | url | async.

var urlResult = await client.Pdf.FromHtmlAsync("<h1>Hi</h1>", extra: new() { ["response"] = "url" });
var job = await client.Convert.FromPathAsync("deck.pptx", extra: new() { ["to"] = "pdf", ["response"] = "async" });
var done = await client.Jobs.WaitAsync(((AsyncResult)job).Id);
(await client.Files.DownloadAsync(done["id"]!.GetValue<string>())).Save("deck.pdf");

Files.DownloadAsync does not send the API key.

Errors

Throws RelayPDFException with Status, Code, Message, and optional RetryAfter.

Methods

Resource Method HTTP
RelayPDF HealthAsync AccountAsync GET /health GET /v1/account
Pdf FromHtmlAsync FromUrlAsync FromMarkdownAsync FromTemplateAsync CreateAsync POST /v1/pdf
Pdf MergeAsync ExtractAsync ProtectAsync UnlockAsync BookmarksAsync RasterAsync FromImagesAsync StampAsync RotateAsync DeletePagesAsync CompressAsync InfoAsync TextAsync FormFieldsAsync FormFillAsync POST /v1/pdf/*
Images FromHtmlAsync FromUrlAsync POST /v1/images
Convert CreateAsync FromHtmlAsync FromPathAsync WkhtmlAsync POST /v1/convert
Templates ListAsync GalleryAsync GetAsync CreateAsync UpdateAsync PublishAsync DeleteAsync DiscardAsync DuplicateAsync VersionsAsync RestoreAsync ValidateAsync PreviewAsync GenerateAsync /v1/templates
Barcodes CreateAsync QrAsync POST /v1/barcodes
Zip CreateAsync POST /v1/zip
Jobs GetAsync WaitAsync GET /v1/jobs/:id
Files DownloadAsync GET /v1/files/:id
Webhooks ListAsync CreateAsync DeleteAsync /v1/webhooks
Webhook.Verify HMAC-SHA256

extra / input dictionaries are merged into the JSON body. REST field names stay camelCase. file values may be byte[] or a data: URL.

Examples

var pdf = await client.Pdf.FromUrlAsync("https://example.com", extra: new()
{
    ["filename"] = "page.pdf",
    ["options"] = new Dictionary<string, object?> { ["format"] = "A4", ["printBackground"] = true },
});
var fromWord = await client.Convert.FromPathAsync("letter.docx", extra: new() { ["to"] = "pdf" });
var pack = await client.Pdf.MergeAsync(new[]
{
    new Dictionary<string, object?> { ["url"] = "https://example.com/cover.pdf" },
    new Dictionary<string, object?> { ["file"] = ((BinaryResult)fromWord).Bytes },
});
await client.Pdf.StampAsync(new() { ["file"] = ((BinaryResult)pack).Bytes, ["text"] = "DRAFT", ["rotate"] = -24 });
var qr = await client.Barcodes.QrAsync("https://relaypdf.com");

Webhooks

Use the raw request body. Secret is the dashboard webhook secret, not the API key.

var ok = Webhook.Verify(
    Environment.GetEnvironmentVariable("RELAYPDF_WEBHOOK_SECRET")!,
    rawBody,
    signatureHeader
);

Header: t=<unix>,v1=<hex>. HMAC-SHA256 of {t}.{raw_body}. Default skew 300s.

License

MIT. Strategic Products LLC, d/b/a RelayPDF.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

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 31 8/27/2026