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
optionsBookOptionsloggerILogger<ChromiumBrowserProvider>
Methods
DisposeAsync
#public ValueTask DisposeAsync()
Closes the browser process if one was launched.
Returns
ValueTaskRenderPdfAsync
#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
htmlstringcancellationTokenCancellationToken
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)
;
}