Rmp.DocProc.HtmlToPdf
1.0.0
dotnet add package Rmp.DocProc.HtmlToPdf --version 1.0.0
NuGet\Install-Package Rmp.DocProc.HtmlToPdf -Version 1.0.0
<PackageReference Include="Rmp.DocProc.HtmlToPdf" Version="1.0.0" />
<PackageVersion Include="Rmp.DocProc.HtmlToPdf" Version="1.0.0" />
<PackageReference Include="Rmp.DocProc.HtmlToPdf" />
paket add Rmp.DocProc.HtmlToPdf --version 1.0.0
#r "nuget: Rmp.DocProc.HtmlToPdf, 1.0.0"
#:package Rmp.DocProc.HtmlToPdf@1.0.0
#addin nuget:?package=Rmp.DocProc.HtmlToPdf&version=1.0.0
#tool nuget:?package=Rmp.DocProc.HtmlToPdf&version=1.0.0
Rmp.DocProc.HtmlToPdf
Async-friendly document formatting package, designed for queued jobs.
Current capability
- HTML file to PDF file conversion using Playwright Chromium.
- HTML file to PNG file conversion (scaffold for additional output formats).
- Optional relative URL normalization to absolute URLs with a provided base URL.
Install
dotnet add package Rmp.DocProc.HtmlToPdf
Browser provisioning (no manual install required by default)
The package tries to auto-install a Playwright browser at runtime if Chromium is missing.
- Default behavior: first run downloads Chromium automatically.
- Good for worker services where you want install-free onboarding.
- Requires network access on first run.
You can still preinstall manually if preferred:
pwsh bin/Debug/net8.0/playwright.ps1 install chromium
or for published artifacts:
pwsh playwright.ps1 install chromium
Important limitation:
- NuGet cannot practically bundle all OS-specific browser binaries inside a single package without major size and distribution drawbacks.
- The closest "bundled" experience is auto-provisioning on first run, or reusing an already installed browser executable/channel.
Usage (queued worker)
using Rmp.DocProc.HtmlToPdf.Abstractions;
using Rmp.DocProc.HtmlToPdf.Html;
using Rmp.DocProc.HtmlToPdf.Pipeline;
var handler = new HtmlToPdfConversionHandler(new HtmlToPdfOptions
{
BaseUrl = "https://example.com",
NormalizeRelativeUrls = true,
PrintBackground = true,
AutoInstallBrowser = true
});
var dispatcher = new ConversionDispatcher(new[] { handler });
var job = new ConversionJob(
SourcePath: "C:/queue/input/123.html",
DestinationPath: "C:/queue/output/123.pdf",
InputFormat: DocumentFormat.Html,
OutputFormat: DocumentFormat.Pdf,
Metadata: new Dictionary<string, string>
{
["jobId"] = "123"
});
await dispatcher.DispatchAsync(job);
Use system Chrome or Edge instead of Playwright-managed Chromium
If your environment already has a managed browser installation, point the handler to it:
var handler = new HtmlToPdfConversionHandler(new HtmlToPdfOptions
{
AutoInstallBrowser = false,
BrowserChannel = "msedge"
// or BrowserExecutablePath = "C:/Program Files/Google/Chrome/Application/chrome.exe"
});
Usage with DI and background worker
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Rmp.DocProc.HtmlToPdf.DependencyInjection;
using Rmp.DocProc.HtmlToPdf.Html;
var host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services
.AddRubiconDocProcHtmlToPdf(
pdfOptions: new HtmlToPdfOptions
{
BaseUrl = "https://example.com/assets/",
NormalizeRelativeUrls = true
},
imageOptions: new HtmlToImageOptions
{
Width = 1280,
Height = 1810
})
.AddRubiconDocProcBackgroundWorker(queueCapacity: 500);
})
.Build();
await host.RunAsync();
Queue producer code can enqueue ConversionJob values through IConversionJobQueue.
Strict enterprise mode (no runtime downloads)
Use strict mode when hosts are locked down and browser binaries must be provisioned by ops.
using Rmp.DocProc.HtmlToPdf.DependencyInjection;
services
.AddRubiconDocProcHtmlToPdfEnterprise(
pdfOptions: new HtmlToPdfOptions
{
BrowserChannel = "msedge"
},
imageOptions: new HtmlToImageOptions
{
BrowserChannel = "msedge"
},
preflightBrowserOnStartup: true)
.AddRubiconDocProcBackgroundWorker();
What strict mode does:
- Forces
AutoInstallBrowser = falsefor registered handlers. - Optionally preflights browser launch at host startup.
- Throws a clear error if no runnable browser is available.
Relative URL handling
When BaseUrl is set and NormalizeRelativeUrls is true:
<base href="...">is injected/updated in<head>.- relative values in
src,href,poster,data, andsrcsetare rewritten to absolute URLs.
This supports the flow where a pre-rendered HTML file is queued and converted later.
Pre-queue normalization
If your producer service needs to rewrite relative URLs before the HTML is saved and queued, call HtmlUrlNormalizer.NormalizeAsync(...) directly and persist the returned HTML.
using Rmp.DocProc.HtmlToPdf.Html;
var normalizedHtml = await HtmlUrlNormalizer.NormalizeAsync(rawHtml, "https://example.com/base/");
await File.WriteAllTextAsync("C:/queue/input/123.html", normalizedHtml);
| Product | Versions 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. |
-
net8.0
- AngleSharp (>= 1.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Playwright (>= 1.55.0)
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 |
|---|---|---|
| 1.0.0 | 0 | 5/20/2026 |