This documentation is also published as Markdown for efficient machine reading: the whole site is indexed at /llms.txt, and every page has a clean Markdown copy at the same URL with .md appended. These are generated from the same source and cost far fewer tokens to read than this rendered HTML.

Skip to main content Skip to navigation

ChromiumBrowserProvider Pennington.Book.Rendering

Owns the process-lifetime Chromium instance used to render composed book HTML to PDF. Registered as a DI singleton — the documented "connection pool" exception to the transient/file-watched default — because launching Chromium is expensive and the browser is safe to reuse across renders. PDF rendering is serialized through a semaphore so a single browser never juggles concurrent paginations.

Constructors

ChromiumBrowserProvider

#
public ChromiumBrowserProvider(BookOptions options, ILogger<ChromiumBrowserProvider> logger)

Creates the provider; Chromium is launched lazily on the first render.

Parameters

options BookOptions
logger ILogger<ChromiumBrowserProvider>

Methods

DisposeAsync

#
public ValueTask DisposeAsync()

Closes the browser process if one was launched.

Returns

ValueTask

RenderPdfAsync

#
public Task<byte[]> RenderPdfAsync(string html, CancellationToken cancellationToken = default)

Renders html to PDF bytes. The HTML must signal completion by setting window.__pagedDone = true (the paged.js after hook the composer wires up); rendering waits up to two minutes for that flag before producing the PDF.

Parameters

html string
cancellationToken CancellationToken

Returns

Task<byte[]>

Pennington.Book.Rendering.ChromiumBrowserProvider

namespace Pennington.Book.Rendering;

/// Owns the process-lifetime Chromium instance used to render composed book HTML to PDF. Registered as a DI singleton — the documented "connection pool" exception to the transient/file-watched default — because launching Chromium is expensive and the browser is safe to reuse across renders. PDF rendering is serialized through a semaphore so a single browser never juggles concurrent paginations.
public class ChromiumBrowserProvider
{
    /// Creates the provider; Chromium is launched lazily on the first render.
    
public ChromiumBrowserProvider(BookOptions options, ILogger<ChromiumBrowserProvider> logger)
; /// Closes the browser process if one was launched.
public ValueTask DisposeAsync()
; /// Renders html to PDF bytes. The HTML must signal completion by setting window.__pagedDone = true (the paged.js after hook the composer wires up); rendering waits up to two minutes for that flag before producing the PDF.
public Task<byte[]> RenderPdfAsync(string html, CancellationToken cancellationToken = default)
; }