Muonroi.Pdf.Governance 1.0.0-alpha.16

This is a prerelease version of Muonroi.Pdf.Governance.
dotnet add package Muonroi.Pdf.Governance --version 1.0.0-alpha.16
                    
NuGet\Install-Package Muonroi.Pdf.Governance -Version 1.0.0-alpha.16
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Muonroi.Pdf.Governance" Version="1.0.0-alpha.16" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Muonroi.Pdf.Governance" Version="1.0.0-alpha.16" />
                    
Directory.Packages.props
<PackageReference Include="Muonroi.Pdf.Governance" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Muonroi.Pdf.Governance --version 1.0.0-alpha.16
                    
#r "nuget: Muonroi.Pdf.Governance, 1.0.0-alpha.16"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Muonroi.Pdf.Governance@1.0.0-alpha.16
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Muonroi.Pdf.Governance&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Muonroi.Pdf.Governance&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Tool

Muonroi.Pdf.Governance

AngleSharp-backed HTML parser, CSS cascade engine, and policy enforcement layer for the Muonroi PDF rendering pipeline.

NuGet License: Apache 2.0

This package provides the concrete implementations of the parsing, cascade, and policy contracts defined in Muonroi.Pdf.Abstractions. It ships an AngleSharp-powered HTML parser (AngleSharpHtmlParser), a CSS cascade engine (AngleSharpCascadeEngine), two ready-to-use CSS policies (DefaultStrictPolicy and LegacyPrintPolicy), and a signature-verification decorator (SignedPdfCssPolicyDecorator). All components are registered automatically when you call AddPdf() from Muonroi.Pdf.

Installation

dotnet add package Muonroi.Pdf.Governance --prerelease

Most applications depend on Muonroi.Pdf (the full engine package), which already pulls in and registers this package. Add Muonroi.Pdf.Governance directly only when you need to reference its concrete types or swap a component before calling AddPdf.

Quick Start

AddPdf (from Muonroi.Pdf) registers AngleSharpHtmlParser, AngleSharpCascadeEngine, and LegacyPrintPolicy via TryAddSingleton. Pre-registering your own implementation before AddPdf is the override mechanism.

// Program.cs
using Microsoft.Extensions.DependencyInjection;
using Muonroi.Pdf.Abstractions.Policy;
using Muonroi.Pdf.Extensions;            // AddPdf
using Muonroi.Pdf.Governance.Policies;   // DefaultStrictPolicy

var builder = WebApplication.CreateBuilder(args);

// Override the default LegacyPrintPolicy with the ultra-strict policy:
builder.Services.AddSingleton<IPdfCssPolicy, DefaultStrictPolicy>();

// AddPdf registers every remaining pipeline component (TryAddSingleton — won't replace the above).
builder.Services.AddPdf(builder.Configuration);

appsettings.json — configure limits and the policy gate:

{
  "PdfConfigs": {
    "Limits": {
      "MaxHtmlBytes": 8388608,
      "MaxDomDepth": 256,
      "MaxElementCount": 100000
    },
    "Policy": {
      "SoftDegradeUnknownDisplay": false,
      "AllowModernLayout": false
    },
    "RequirePolicySignature": false
  }
}

Features

  • AngleSharp HTML parser — parses raw HTML into a DOM, enforcing MaxHtmlBytes, MaxElementCount, and MaxDomDepth limits before returning an IParsedDocument. Throws PdfInputLimitException on violation.
  • AngleSharp cascade engine — applies an optional user stylesheet by injecting a <style> element into <head>, then wraps the result as an AngleSharpStyledDocument for the box-tree stage.
  • DefaultStrictPolicy (Id = "default-strict-v1") — blocks external @import, @keyframes, CSS transitions, display:flex/grid, float, position:absolute/fixed/sticky, border-collapse:collapse, <script> elements, non-http(s)/mailto link schemes, and the unsupported visual properties filter, clip-path, backdrop-filter, mix-blend-mode (raw-CSS scan; AngleSharp drops these from the CSSOM). Fail-loud on every violation.
  • LegacyPrintPolicy (Id = "legacy-print-v1") — CSS 2.1 print subset; relaxes float, position:absolute, and border-collapse:collapse relative to the strict policy. Optionally accepts display:flex/grid when AllowModernLayout = true. Soft-degrade mode (SoftDegradeUnknownDisplay = true) downgrades flex/grid violations from errors to warnings and falls back to display:block.
  • SignedPdfCssPolicyDecorator — wraps any IPdfCssPolicy; when RequirePolicySignature = true, calls a provided Func<bool> verifier and throws PdfPolicyException (gov.policy.signature-invalid) on failure before delegating to the inner policy.
  • AOT-compatibleIsAotCompatible = true; AngleSharp.Css trim warnings originate in AngleSharp internals and are mitigated via TrimmerRootDescriptor in the AOT sample.

Configuration

All tunables live under the PdfConfigs section (bound by AddPdf with ValidateOnStart):

Key Type Default Description
PdfConfigs:Limits:MaxHtmlBytes long 8388608 Maximum HTML input size in bytes
PdfConfigs:Limits:MaxDomDepth int 256 Maximum DOM nesting depth
PdfConfigs:Limits:MaxElementCount int 100000 Maximum element count after parsing
PdfConfigs:Policy:SoftDegradeUnknownDisplay bool false Downgrade display:flex/grid to warning + block fallback (LegacyPrintPolicy only)
PdfConfigs:Policy:AllowModernLayout bool false Accept flex/grid when the engine's FlexLayoutEngine is active (LegacyPrintPolicy only)
PdfConfigs:RequirePolicySignature bool false Require a valid policy-config signature before validation proceeds

PdfPolicySettings is the strongly typed options class for the Policy sub-section. PdfConfigs.PdfLimits is the strongly typed options class for Limits.

API Reference

Type Purpose
AngleSharpHtmlParser Implements IHtmlParser; parses HTML + enforces structural limits
AngleSharpCascadeEngine Implements ICssCascadeEngine; injects user stylesheet + wraps DOM
DefaultStrictPolicy Implements IPdfCssPolicy; ultra-strict gate, all unsupported CSS is an error
LegacyPrintPolicy Implements IPdfCssPolicy; CSS 2.1 print subset with optional soft-degrade / modern-layout modes
SignedPdfCssPolicyDecorator Decorator around IPdfCssPolicy; adds signature-verification gate
PdfPolicySettings Options record bound from PdfConfigs:Policy; controls SoftDegradeUnknownDisplay and AllowModernLayout
PdfConfigs Root configuration class bound from the PdfConfigs section
PdfConfigs.PdfLimits Nested options record; controls structural input limits

Samples

No dedicated sample ships for this package. See the full engine sample for end-to-end usage:

  • Muonroi.Pdf.Samples — demonstrates AddPdf registration, font configuration, and PDF rendering

Compatibility

  • Target framework: net8.0
  • License: Apache-2.0 (OSS)
  • Muonroi.Pdf.Abstractions — contracts (IPdfCssPolicy, IHtmlParser, ICssCascadeEngine, IPdfDocumentContext)
  • Muonroi.Pdf — full engine package; calls AddPdf which registers all governance components
  • Muonroi.Pdf.Enterprise — enterprise extensions; decorates the policy and cascade registrations with commercial features

License

Apache-2.0. See LICENSE-APACHE.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Muonroi.Pdf.Governance:

Package Downloads
Muonroi.BuildingBlock.All

Metapackage for Muonroi Building Block - Includes all sub-packages for a complete infrastructure setup.

Muonroi.Pdf

HTML/CSS to PDF layout engine: box-tree construction, pagination, and rendering coordination for Muonroi applications.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.16 77 6/22/2026
1.0.0-alpha.15 91 5/31/2026