Lyo.Web.WebRenderer
1.0.3
See the version list below for details.
dotnet add package Lyo.Web.WebRenderer --version 1.0.3
NuGet\Install-Package Lyo.Web.WebRenderer -Version 1.0.3
<PackageReference Include="Lyo.Web.WebRenderer" Version="1.0.3" />
<PackageVersion Include="Lyo.Web.WebRenderer" Version="1.0.3" />
<PackageReference Include="Lyo.Web.WebRenderer" />
paket add Lyo.Web.WebRenderer --version 1.0.3
#r "nuget: Lyo.Web.WebRenderer, 1.0.3"
#:package Lyo.Web.WebRenderer@1.0.3
#addin nuget:?package=Lyo.Web.WebRenderer&version=1.0.3
#tool nuget:?package=Lyo.Web.WebRenderer&version=1.0.3
Lyo.Web.WebRenderer
Server-side rendering of Razor components and HTML→PDF conversion. Razor rendering uses Microsoft.AspNetCore.Components.Web.HtmlRenderer; PDF conversion is driven by PuppeteerSharp against a locally-installed Chromium/Chrome browser.
Examples
DI registration (Extensions.cs)
services.AddWebRendererServiceFromConfiguration(builder.Configuration);
Surface (IWebRendererService)
The service exposes three families of operations plus three observability events.
Surface (IWebRendererService) — Render Razor components
Method (sync + Async overloads) |
Result |
|---|---|
RenderToHtml<T>(parameterDictionary?) |
HTML string for component T : IComponent. |
RenderToHtml<T, TOptions>(options) |
HTML string passing a strongly-typed options object as the Options parameter. |
RenderToHtmlBytes<T>(parameterDictionary?) |
UTF-8 bytes (records size metric). |
RenderToHtmlBytes<T, TOptions>(options) |
Same, with typed options. |
RenderToFile<T>(filePath, parameterDictionary?) |
Writes HTML to disk at filePath. |
RenderToFile<T, TOptions>(filePath, options) |
Same, with typed options. |
Surface (IWebRendererService) — HTML → PDF conversion
Method (sync + Async overloads) |
Result |
|---|---|
ConvertHtmlToPdf(string htmlContent) |
PDF bytes from an HTML string. |
ConvertHtmlToPdf(byte[] htmlBytes) |
PDF bytes from already-encoded HTML. |
ConvertHtmlToPdfFromFile(string htmlFilePath) |
PDF bytes from an HTML file on disk. |
ConvertHtmlToPdfFile(string htmlContent, string pdfFilePath) |
Writes PDF to pdfFilePath. |
ConvertHtmlToPdfFile(byte[] htmlBytes, string pdfFilePath) |
Same, from bytes. |
ConvertHtmlFileToPdfFile(string htmlFilePath, string? pdfFilePath = null) |
End-to-end file → file (PDF path defaults to <htmlFilePath>.pdf when null). |
The current interface only exposes Razor render and HTML→PDF; there is no in-process screenshot API. For raw screenshots, use PuppeteerSharp directly through
BrowserExePath.
Surface (IWebRendererService) — Events
ComponentRendered, ComponentRenderedToBytes, ComponentSavedToFile fire after the corresponding render operations and carry the resulting payload plus parameter and options snapshots — useful for downstream archival or diffing.
Options (WebRenderOptions)
Configuration section: WebRenderOptions.
| Property | Default | Description |
|---|---|---|
BrowserExePath |
Utilities.DetectBrowserPath(SupportedBrowser.Chrome) |
Path to the Chromium/Chrome executable used by PuppeteerSharp for HTML→PDF. |
EnableMetrics |
false |
When true and an IMetrics is registered, records timers/counters/gauges (see below). |
When EnableMetrics is false (default) the service uses NullMetrics.Instance, so registering IMetrics is optional.
Metrics emitted (see Constants.cs) include webrenderer.render_to_html(.bytes|_to_file).{duration,success,failure,size_bytes} and
webrenderer.convert_html_to_pdf.{duration,success,failure,size_bytes,input_size_bytes}, tagged with component_type / operation.
DI registration (Extensions.cs)
This binds WebRenderOptions from WebRenderOptions (default section name) and registers: - A scoped Microsoft.AspNetCore.Components.Web.HtmlRenderer (resolved with the host’s IServiceProvider and ILoggerFactory). - A scoped IWebRendererService → WebRendererService, optionally consuming registered ILogger<WebRendererService> and IMetrics. Pass configSectionName to the extension if you need a non-default section name. There is currently no inline-options overload — register WebRenderOptions yourself before calling the extension if you need to bypass configuration.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Exceptions— (direct, lyo)Lyo.Metrics— (direct, lyo)Microsoft.AspNetCore.Components.Web10.0.5— (direct, microsoft)Microsoft.Extensions.Configuration10.0.5— (direct, microsoft)Microsoft.Extensions.Configuration.Binder10.0.5— (direct, microsoft)Microsoft.Extensions.DependencyInjection.Abstractions10.0.5— (direct, microsoft)Microsoft.Extensions.Logging.Abstractions10.0.5— (direct, microsoft)PuppeteerSharp24.0.0— (direct, third-party)Microsoft.Extensions.Options.ConfigurationExtensions10.0.5— (transitive, microsoft)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Lyo.Exceptions (>= 1.0.3)
- Lyo.Metrics (>= 1.0.3)
- Microsoft.AspNetCore.Components.Web (>= 10.0.5)
- Microsoft.Extensions.Configuration (>= 10.0.5)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.5)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- PuppeteerSharp (>= 24.0.0 && < 25.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Lyo.Web.WebRenderer:
| Package | Downloads |
|---|---|
|
Lyo.Pdf.Web.Components
Reusable Blazor components for PDF workbenches, annotation helpers, and HTML to PDF workflows. |
|
|
Lyo.Reporting.Web
Blazor report viewer, business templates, and HTML/PDF report renderers for Lyo Reporting. |
GitHub repositories
This package is not used by any popular GitHub repositories.