|
|
|
Cross-Platform Library (SelectPdf.HtmlToPdf.Universal) - Linux, macOS (Apple Silicon), Docker, .NET Standard 2.0 - .NET 10 |
|
SelectPdf.HtmlToPdf.Universal is the free, cross-platform edition of the SelectPdf HTML to PDF converter. It runs on Windows, Linux and macOS (including Docker containers) on modern .NET, and keeps the classes and members of this library. Code written against Select.HtmlToPdf moves over with mechanical changes - new package references, the SelectPdf.Universal namespace and SelectPdf's own drawing types instead of System.Drawing - see Migrating Code below. Like this library, the free edition generates PDF documents up to 5 pages long.
Use this library (Select.HtmlToPdf) for Windows-only .NET Framework / .NET applications. Use SelectPdf.HtmlToPdf.Universal when the application must run on Linux or macOS, in Docker containers, or when the same code base must be deployable on more than one operating system.
HTML to PDF conversion with a Chromium-based rendering engine - full HTML5, CSS3, web fonts and JavaScript support (the same engine family as the Chromium engine in this library).
Rich conversion options - page settings, resize-to-fit, document properties, viewer preferences, security (passwords and permissions), custom headers and footers (including HTML), automatic and manual page breaks, HTTP headers, cookies, authentication and proxy, internal and external links, automatic bookmarks.
Bundled fonts - the Liberation Sans, Serif and Mono families (metric-compatible with Arial, Times New Roman and Courier New) ship with the library, so text renders correctly even on minimal Linux images or containers with no fonts installed.
No System.Drawing dependency - drawing-related types (colors, points, sizes) come from a lightweight SelectPdf.Universal.Drawing namespace included in the library.
Free - generates PDF documents up to 5 pages long. For unlimited output and the full PDF creation / editing feature set, use the commercial SelectPdf.Universal package.
A typical installation is two steps: install the main library package, then one native engine package matching the deployment platform.
1. Main library packages
The free cross-platform HTML to PDF converter, AnyCPU. Targets .NET Standard 2.0 (usable from .NET Framework 4.6.1+, .NET Core 2.0+ and .NET 5+), with dedicated builds for .NET 8 and .NET 10. Generates PDF documents up to 5 pages long.
https://www.nuget.org/packages/SelectPdf.HtmlToPdf.Universal/
The full commercial cross-platform library - unlimited output, plus PDF creation and editing, merge, forms, digital signatures, encryption, PDF/A / PDF/X, tagged / accessible PDF, PDF to text and PDF to image.
2. Native engine packages (install the one matching the deployment platform; several can be installed side by side for multi-platform publishing)
Rendering engine for Windows, x64.
https://www.nuget.org/packages/SelectPdf.Universal.Native.win-x64/
Rendering engine for Windows, x86.
https://www.nuget.org/packages/SelectPdf.Universal.Native.win-x86/
Rendering engine for Linux, x64.
https://www.nuget.org/packages/SelectPdf.Universal.Native.linux-x64/
Rendering engine for Linux, ARM 64-bit.
https://www.nuget.org/packages/SelectPdf.Universal.Native.linux-arm64/
Rendering engine for macOS on Apple Silicon (ARM 64-bit), macOS 12 (Monterey) or newer.
https://www.nuget.org/packages/SelectPdf.Universal.Native.osx-arm64/
Windows (x64 / x86) - full support.
Linux (x64 / arm64) - full support, including minimal server images and Docker containers with no extra OS packages (the native engine package bundles everything, and rendering is headless - no X server needed).
macOS (Apple Silicon) - full support. Requires macOS 12 (Monterey) or newer, and the engine links only macOS system frameworks, so there is nothing extra to install. On Intel Macs the engine is not available - no osx-x64 package is produced.
The managed library is platform-neutral (AnyCPU). The Chromium engine runs inside the application when the native package matches the architecture of the application's process (win-x86 for a 32-bit Windows process), and in a separate process otherwise - so on Windows a 32-bit or a 64-bit application can use either the win-x86 or the win-x64 package. The native package must still match the operating system and the processor family: an x64 package does not run on an Arm64 machine.
Linux images must be glibc-based - glibc 2.30 or newer, which every mainstream distribution released since about 2020 provides (Ubuntu 20.04+, Debian 11+, RHEL 9+). Alpine images are built on musl and are not supported.
Chromium-based rendering is processor bound - allow at least 1 core and 2 GB of RAM per process or container, and prefer 2 or more cores when conversion latency matters.
Hosted platforms: Azure App Service on Windows and on Linux (Basic plan or above), Azure Container Apps, Azure Kubernetes Service, and Azure Functions on an App Service or Premium plan. See Deployment to Microsoft Azure.
For container deployment details (Linux and Windows containers), see Deployment to Docker.
SelectPdf.HtmlToPdf.Universal keeps the classes, members and overloads of this library wherever they could be kept, so migration is mostly mechanical:
Replace the Select.HtmlToPdf or Select.HtmlToPdf.NetCore package and the Chromium or Blink companion packages with SelectPdf.HtmlToPdf.Universal plus the matching SelectPdf.Universal.Native.<rid> package. Remove any direct reference to Select.HtmlToPdf.dll, the engine files the project carries (Select.Html.dep and the engine folders) and any build step that copies them - the native package deploys its files itself.
Change using SelectPdf; to using SelectPdf.Universal; (and Imports SelectPdf to Imports SelectPdf.Universal). The class names stay the same; the namespace changed.
Replace System.Drawing types in SelectPdf calls: colors with PdfColor (or SelectPdf.Universal.Drawing.Color), points, rectangles and sizes with the types of the SelectPdf.Universal.Drawing namespace, System.Drawing.Font with PdfFont or PdfSystemFont, and images with a Stream or a byte[].
Remove the engine selection: SelectPdf.Universal renders with Chromium only, so the WebKit, WebKit Restricted and Blink engines and their settings are gone, and CefEnginePath is named ChromiumEnginePath. An application that rendered with the default WebKit engine should review its output: the layout, page breaks and page count follow the Chromium engine.
Check the fonts: an installed font is found by its exact family name on the machine the application runs on, and Windows fonts such as Arial are usually not installed on Linux servers or in containers. The bundled Liberation Sans, Serif and Mono families are available everywhere.
HtmlToImage is part of the full SelectPdf.Universal package only; an application that uses it needs that package (same namespace, same code).
The SelectPdf.Universal documentation has the complete list - every removed or renamed member, how fonts are found on each platform, and the defaults that changed (the engine runs inside the application when the native package matches the process architecture, conversions run 8 at a time, the HTTP cache is kept between conversions, and encryption uses AES-256) - in its Migrating to SelectPdf.HtmlToPdf.Universal topic. The cross-platform library is presented at https://selectpdf.com/pdf-library-cross-platform/.