SelectPdf.Api 1.5.0

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

SelectPdf Online REST API - .NET Client

SelectPdf Online REST API is a professional solution for managing PDF documents online. It now has a dedicated, easy to use, .NET client library that can be setup in minutes.

Try without an API key (demo mode)

using System;
using System.IO;
using SelectPdf.Api;

class Program {
    static void Main() {
        // No API key -> keyless demo mode (5-page cap, watermarked output, Chromium engine).
        HtmlToPdfClient client = new HtmlToPdfClient(); // also: new HtmlToPdfClient("demo")
        byte[] pdf = client.convertUrl("https://example.com");
        File.WriteAllBytes("demo.pdf", pdf);
        Console.WriteLine("Pages: {0}", client.getNumberOfPages());
        if (client.WasClamped)
            Console.WriteLine("Server clamped: {0}", string.Join(",", client.ClampedFields));
        // Upgrade for unwatermarked, unlimited-page PDFs: https://selectpdf.com/pricing/
    }
}

Demo mode limitations

Demo mode is intended for evaluating the API. To keep the public endpoint stable and prevent abuse, several limits and restrictions apply that don't exist on a paid endpoint.

Output:

  • 5 pages maximum. Pages beyond the fifth are dropped, then a final branding/notice page is appended (so a typical demo PDF is 1–6 pages depending on the source).
  • Watermarked. A diagonal SelectPdf demo stamp is rendered on every page plus a footer attribution line. The watermark is added by the rendering engine itself — there is no client- or server-side post-processing that can be disabled.
  • Chromium rendering engine only. If you call setRenderingEngine(...) with WebKit, Restricted, or Blink, the server silently force-clamps to Chromium. The response carries WasClamped == true and ClampedFields will include engine.

Parameters not allowed:

Parameter / setter Behavior in demo mode
setUserPassword(...) Throws DemoUnsupportedException client-side (before the request leaves the SDK).
setOwnerPassword(...) Same — throws DemoUnsupportedException.
async = true Not supported. The demo endpoint is synchronous only; there is no /api2/asyncjob/ polling for demo conversions.

The two clamped time parameters are accepted but capped:

Parameter Production cap Demo cap
setNavigationTimeout(...) (max_load_time) up to 120 s clamped to 15 s
setConversionDelay(...) (min_load_time) up to 120 s clamped to 5 s

When clamping happens, the response sets WasClamped = true and lists the affected field names in ClampedFields.

Silently dropped fields:

A few request fields are accepted but never honored by the demo endpoint — they're zeroed out server-side because they would compromise the demo's safety posture. Any caller-supplied value is reported back via WasAnyFieldDropped / DroppedFields so you can see what was ignored.

Field Reason
auth_username / auth_password Would let demo callers pump credentials at internal HTTP-Basic endpoints.
cookies (setCookies(...)) / cookies_string Session-hijack vector if combined with a target inside our own infra.
raw_parameters Escape hatch that bypasses the parameter clamp; must stay dropped.
pdf_name Demo always returns inline demo.pdf.
async Demo is sync-only.

Distinct from ClampedFields: clamped means the value was modified (capped, force-set), dropped means it was thrown away.

URLs:

The demo endpoint accepts only publicly reachable http:// / https:// URLs. Requests targeting non-public destinations are rejected with DemoSafetyException (HTTP 400). Use a paid endpoint if you need to convert content from a private network.

Rate limits:

Layer Default Failure
Per-IP 30 requests / rolling hour DemoRateLimitException with Reason="per_ip", RetryAfter≈3600
Daily global ceiling 50,000 successful conversions / 24 h across all clients DemoRateLimitException with Reason="daily_cap"
Concurrency 4 in-flight conversions globally DemoRateLimitException with Reason="concurrency", RetryAfter≈5

Retry-After is taken from the response header. Both the per-IP and daily counters include rejected attempts, so spamming after a block doesn't reset anything.

Request size:

  • 1 MB request body cap. Larger payloads return HTTP 413 — typically only an issue if you're inlining a very large HTML string.

Response:

  • No X-SelectPdf-Credits-Total / X-SelectPdf-Credits-Remaining headers (the demo endpoint is keyless, so there's no billing account to attribute usage to). On the SDK client these surface as client.CreditsTotal == null and client.CreditsRemaining == null.
  • client.Mode == "demo" (helper: client.IsDemoResponse == true).
  • client.ExecutionMode is either "in-process" or "worker" depending on how the server was deployed.

Catching demo-mode errors

The SDK exposes three typed exceptions for demo-specific failure modes; everything else surfaces as a regular ApiException (paid-endpoint errors) or WebException (network failures):

try
{
    HtmlToPdfClient client = new HtmlToPdfClient(); // demo mode
    byte[] pdf = client.convertUrl("https://example.com");
}
catch (DemoRateLimitException ex)
{
    // Reason: "per_ip" | "daily_cap" | "concurrency"
    Console.WriteLine("Rate limited: {0}, retry after {1}s", ex.Reason, ex.RetryAfter);
    Console.WriteLine("Upgrade: {0}", ex.UpgradeUrl);
}
catch (DemoSafetyException ex)
{
    // The supplied URL was rejected. Use a paid endpoint for non-public targets.
    Console.WriteLine("URL rejected: {0}", ex.Message);
}
catch (DemoUnsupportedException ex)
{
    // Field: which parameter is unavailable in demo mode
    Console.WriteLine("'{0}' not available in demo mode. Upgrade: {1}", ex.Field, ex.UpgradeUrl);
}

For unwatermarked production output without these limits, pass a real API key — same client class, same setters:

HtmlToPdfClient client = new HtmlToPdfClient("Your API key here");

IsDemoMode on the client is set at construction time and stable for the client's lifetime, so a real-key client will never silently fall back to demo behavior.

Installation

Download selectpdf-api-dotnet-client-1.5.0.zip, unzip it and add a reference to SelectPdf.Api.dll to your project.

OR

Install SelectPdf .NET Client for Online API via Nuget: SelectPdf API on Nuget.

Install-Package SelectPdf.Api -Version 1.5.0

OR

Clone selectpdf-api-dotnet-client from Github and build the library.

git clone https://github.com/selectpdf/selectpdf-api-dotnet-client
cd selectpdf-api-dotnet-client

HTML To PDF API - .NET Client

SelectPdf HTML To PDF Online REST API is a professional solution that lets you create PDF from web pages and raw HTML code in your applications. The API is easy to use and the integration takes only a few lines of code.

Features

  • Create PDF from any web page or html string.
  • Full html5/css3/javascript support.
  • Set PDF options such as page size and orientation, margins, security, web page settings.
  • Set PDF viewer options and PDF document information.
  • Create custom headers and footers for the pdf document.
  • Hide web page elements during the conversion.
  • Automatically generate bookmarks during the html to pdf conversion.
  • Support for partial page conversion.
  • Easy integration, no third party libraries needed.
  • Works in all programming languages.
  • No installation required.

Sign up for for free to get instant API access to SelectPdf HTML to PDF API.

Sample Code

using System;
using SelectPdf.Api;

namespace SelectPdf.Api.Tests
{
    class Program
    {
        static void Main(string[] args)
        {
            string url = "https://selectpdf.com";
            string localFile = "Test.pdf";
            string apiKey = "Your API key here";

            Console.WriteLine("This is SelectPdf-{0}.", ApiClient.CLIENT_VERSION);

            try
            {
                HtmlToPdfClient client = new HtmlToPdfClient(apiKey);

                // set parameters - see full list at https://selectpdf.com/html-to-pdf-api/
                client
                    // main properties

                    .setPageSize(PageSize.A4) // PDF page size
                    .setPageOrientation(PageOrientation.Portrait) // PDF page orientation
                    .setMargins(0) // PDF page margins
                    .setRenderingEngine(RenderingEngine.WebKit) // rendering engine
                    .setConversionDelay(1) // conversion delay
                    .setNavigationTimeout(30) // navigation timeout 
                    .setShowPageNumbers(false) // page numbers
                    .setPageBreaksEnhancedAlgorithm(true) // enhanced page break algorithm

                    // additional properties

                    // .setUseCssPrint(true) // enable CSS media print
                    // .setDisableJavascript(true) // disable javascript
                    // .setDisableInternalLinks(true) // disable internal links
                    // .setDisableExternalLinks(true) // disable external links
                    // .setKeepImagesTogether(true) // keep images together
                    // .setScaleImages(true) // scale images to create smaller pdfs
                    // .setSinglePagePdf(true) // generate a single page PDF
                    // .setUserPassword("password") // secure the PDF with a password

                    // generate automatic bookmarks

                    // .setPdfBookmarksSelectors("H1, H2") // create outlines (bookmarks) for the specified elements
                    // .setViewerPageMode(PageMode.UseOutlines) // display outlines (bookmarks) in viewer
                ;

                Console.WriteLine("Starting conversion ...");

                // convert url to file
                client.convertUrlToFile(url, localFile);

                // convert url to memory
                // byte[] pdf = client.convertUrl(url);

                // convert html string to file
                // client.convertHtmlStringToFile("This is some <b>html</b>.", localFile);

                // convert html string to memory
                // byte[] pdf = client.convertHtmlString("This is some <b>html</b>.");

                Console.WriteLine("Finished! Number of pages: {0}.", client.getNumberOfPages());

                // get API usage
                UsageClient usageClient = new UsageClient(apiKey);
                UsageInformation usage = usageClient.getUsage(false);
                Console.WriteLine("Conversions remained this month: {0}.", usage.Available);
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: " + ex.Message);
            }
        }
    }
}

Pdf Merge API

SelectPdf Pdf Merge REST API is an online solution that lets you merge local or remote PDFs into a final PDF document.

Features

  • Merge local PDF document.
  • Merge remote PDF from public url.
  • Set PDF viewer options and PDF document information.
  • Secure generated PDF with a password.
  • Works in all programming languages.

See PDF Merge API page for full list of parameters.

Sample Code

using System;
using SelectPdf.Api;

namespace SelectPdf.Api.Tests
{
    class Program
    {
        static void Main(string[] args)
        {
            string testUrl = "https://selectpdf.com/demo/files/selectpdf.pdf";
            string testPdf = "Input.pdf";
            string localFile = "Result.pdf";
            string apiKey = "Your API key here";

            Console.WriteLine("This is SelectPdf-{0}.", ApiClient.CLIENT_VERSION);

            try
            {
                PdfMergeClient client = new PdfMergeClient(apiKey);

                // set parameters - see full list at https://selectpdf.com/pdf-merge-api/
                client
                    // specify the pdf files that will be merged (order will be preserved in the final pdf)

                    .addFile(testPdf) // add PDF from local file
                    .addUrlFile(testUrl) // add PDF From public url
                    // .addFile(testPdf, "pdf_password") // add PDF (that requires a password) from local file
                    // .addUrlFile(testUrl, "pdf_password") // add PDF (that requires a password) from public url
                ;

                Console.WriteLine("Starting pdf merge ...");

                // merge pdfs to local file
                client.saveToFile(localFile);

                // merge pdfs to memory
                // byte[] pdf = client.save();

                Console.WriteLine("Finished! Number of pages: {0}.", client.getNumberOfPages());

                // get API usage
                UsageClient usageClient = new UsageClient(apiKey);
                UsageInformation usage = usageClient.getUsage(false);
                Console.WriteLine("Conversions remained this month: {0}.", usage.Available);
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: " + ex.Message);
            }
        }
    }
}

Pdf To Text API

SelectPdf Pdf To Text REST API is an online solution that lets you extract text from your PDF documents or search your PDF document for certain words.

Features

  • Extract text from PDF.
  • Search PDF.
  • Specify start and end page for partial file processing.
  • Specify output format (plain text or html).
  • Use a PDF from an online location (url) or upload a local PDF document.

See Pdf To Text API page for full list of parameters.

Sample Code - Pdf To Text

using System;
using SelectPdf.Api;

namespace SelectPdf.Api.Tests
{
    class Program
    {
        static void Main(string[] args)
        {
            string testUrl = "https://selectpdf.com/demo/files/selectpdf.pdf";
            string testPdf = "Input.pdf";
            string localFile = "Result.txt";
            string apiKey = "Your API key here";

            Console.WriteLine("This is SelectPdf-{0}.", ApiClient.CLIENT_VERSION);

            try
            {
                PdfToTextClient client = new PdfToTextClient(apiKey);

                // set parameters - see full list at https://selectpdf.com/pdf-to-text-api/
                client
                    .setStartPage(1) // start page (processing starts from here)
                    .setEndPage(0) // end page (set 0 to process file til the end)
                    .setOutputFormat(OutputFormat.Text) // set output format (0-Text or 1-HTML)
                ;

                Console.WriteLine("Starting pdf to text ...");

                // convert local pdf to local text file
                client.getTextFromFileToFile(testPdf, localFile);

                // extract text from local pdf to memory
                // string text = client.getTextFromFile(testPdf);
                // print text
                // Console.WriteLine(text);

                // convert pdf from public url to local text file
                // client.getTextFromUrlToFile(testUrl, localFile);

                // extract text from pdf from public url to memory
                // string text = client.getTextFromUrl(testUrl);
                // print text
                // Console.WriteLine(text);

                Console.WriteLine("Finished! Number of pages processed: {0}.", client.getNumberOfPages());

                // get API usage
                UsageClient usageClient = new UsageClient(apiKey);
                UsageInformation usage = usageClient.getUsage(false);
                Console.WriteLine("Conversions remained this month: {0}.", usage.Available);
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: " + ex.Message);
            }
        }
    }
}

Sample Code - Search Pdf

using System;
using SelectPdf.Api;

namespace SelectPdf.Api.Tests
{
    class Program
    {
        static void Main(string[] args)
        {
            string testUrl = "https://selectpdf.com/demo/files/selectpdf.pdf";
            string testPdf = "Input.pdf";
            string apiKey = "Your API key here";

            Console.WriteLine("This is SelectPdf-{0}.", ApiClient.CLIENT_VERSION);

            try
            {
                PdfToTextClient client = new PdfToTextClient(apiKey);

                // set parameters - see full list at https://selectpdf.com/pdf-to-text-api/
                client
                    .setStartPage(1) // start page (processing starts from here)
                    .setEndPage(0) // end page (set 0 to process file til the end)
                    .setOutputFormat(OutputFormat.Text) // set output format (0-Text or 1-HTML)
                ;

                Console.WriteLine("Starting search pdf ...");

                // search local pdf
                IList<TextPosition> results = client.searchFile(testPdf, "pdf");

                // search pdf from public url
                // IList<TextPosition> results = client.searchUrl(testUrl, "pdf");

                Console.WriteLine("Search results:\n{0}\nSearch results count: {1}.", string.Join("\n", results), results.Count);

                Console.WriteLine("Finished! Number of pages processed: {0}.", client.getNumberOfPages());

                // get API usage
                UsageClient usageClient = new UsageClient(apiKey);
                UsageInformation usage = usageClient.getUsage(false);
                Console.WriteLine("Conversions remained this month: {0}.", usage.Available);
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: " + ex.Message);
            }
        }
    }
}
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 net20 is compatible.  net35 was computed.  net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on SelectPdf.Api:

Package Downloads
asiris_clean_dotnet8.Infrastructure

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.0 0 4/30/2026
1.4.0 63,574 3/24/2022
1.3.1 4,602 6/14/2021
1.3.0 2,306 6/11/2021
1.2.0 2,308 6/2/2021
1.1.5 3,229 5/11/2021
1.1.4 2,236 5/4/2021
1.1.3 2,249 5/4/2021
1.1.2 2,278 4/29/2021
1.1.1 2,268 4/23/2021
1.1.0 2,326 4/14/2021
1.0.1 2,659 11/3/2020
1.0.0 2,510 7/16/2020

Added support for the new Chromium rendering engine (RenderingEngine.Chromium). Added keyless demo-mode access: construct HtmlToPdfClient() with no key, an empty string, or "demo" to use the public demo endpoint (5-page cap + watermarked output, no signup). Demo errors surface as typed exceptions: DemoRateLimitException, DemoSafetyException, DemoUnsupportedException. New properties on HtmlToPdfClient expose demo response metadata: IsDemoMode, IsDemoResponse, ExecutionMode, ClampedFields, WasClamped, DroppedFields, WasAnyFieldDropped (the latter two surface the X-SelectPdf-Demo-Dropped server header for fields the demo endpoint silently discards — auth credentials, cookies, raw_parameters, pdf_name, async). Standard SelectPdf response headers are now captured correctly on the .NET Standard 2.0 / HttpClient code path (server emits them on Content.Headers; that path now reads from both header collections).