Holos.Reporting.Pdf 27.0.0-holos.2

This is a prerelease version of Holos.Reporting.Pdf.
dotnet add package Holos.Reporting.Pdf --version 27.0.0-holos.2
                    
NuGet\Install-Package Holos.Reporting.Pdf -Version 27.0.0-holos.2
                    
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="Holos.Reporting.Pdf" Version="27.0.0-holos.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Holos.Reporting.Pdf" Version="27.0.0-holos.2" />
                    
Directory.Packages.props
<PackageReference Include="Holos.Reporting.Pdf" />
                    
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 Holos.Reporting.Pdf --version 27.0.0-holos.2
                    
#r "nuget: Holos.Reporting.Pdf, 27.0.0-holos.2"
                    
#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 Holos.Reporting.Pdf@27.0.0-holos.2
                    
#: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=Holos.Reporting.Pdf&version=27.0.0-holos.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Holos.Reporting.Pdf&version=27.0.0-holos.2&prerelease
                    
Install as a Cake Tool

Majorsilence.Pdf

Zero-dependency PDF generation for .NET. Pure managed code — no native binaries, no libgdiplus, no Chromium. Produces PDF 1.4, PDF 1.7, and PDF 2.0 output with optional PDF/A conformance. Native-AOT-compatible, which makes it a good fit for AWS Lambda, Azure Functions, and other serverless/container workloads where cold-start size and native dependencies matter.

Majorsilence.Pdf is tri licensed under Apache-2.0, MIT, or BSD-3-Clause. Pick your choice.

  • SPDX-License-Identifier: MIT OR Apache-2.0 OR BSD-3-Clause
  • Copyright (C) 2026 Peter Gill peter@majorsilence.com

At a glance

Capability Package
Text, shapes, images, tables, links Majorsilence.Pdf
Fluent flow layout — rows, columns, boxes, splitting text/tables, "Page X of Y" headers and footers (PdfLayout) Majorsilence.Pdf
PDF/A-1b, PDF/A-2b, PDF/A-3b conformance Majorsilence.Pdf
Multi-document merge Majorsilence.Pdf
AES-128 (R=4) / AES-256 (R=6) password protection Majorsilence.Pdf.Security
Permission flags (print, copy, edit) Majorsilence.Pdf.Security
PKCS#7 digital signatures Majorsilence.Pdf.Security
Markdown rendering (headings, lists, code, tables, links) Majorsilence.Pdf.Markdown
Live browser preview while you code (mspdf-preview) Majorsilence.Pdf.Previewer (dotnet tool)

Targets .NET Standard 2.0, .NET 6, .NET 8, and .NET 10 — usable from .NET Framework 4.6.1+ up through the latest runtime.

Quick Start

using Majorsilence.Pdf;

PdfDocument.Create()
    .WithTitle("My Report")
    .AddPage(PageSizes.A4, canvas =>
    {
        canvas.DrawText("Hello, World!", 72, 72, TextStyle.Default.WithSize(24));
        canvas.DrawRectangle(72, 120, 200, 60,
            ShapeStyle.Filled(PdfColor.LightGray).WithStroke(PdfColor.Black, 1f));
    })
    .Save("report.pdf");

Features

Drawing primitives

Method Description
DrawText Single-line text at a point
DrawTextBox Multi-line word-wrapped text in a bounding box; returns overflow index for pagination
DrawLine Straight line segment
DrawRectangle Rectangle with optional fill and border
DrawEllipse Ellipse / circle
DrawPolygon Arbitrary closed polygon
DrawCurve Cubic Bézier curve
DrawImage Embedded bitmap image
DrawTable Table with header row, alternating-row backgrounds, borders, and cell padding
MeasureTextWidth Measure the pixel width of a string
MeasureTextBoxHeight Measure the height of wrapped text in a given width

Styles

TextStyle — fluent immutable builder:

TextStyle.Default
    .WithSize(14)
    .WithBold(true)
    .WithColor(PdfColor.FromHex("#003366"))
    .WithAlignment(TextAlignment.Center)

ShapeStyle — fill, border, and opacity:

ShapeStyle.Filled(PdfColor.FromRgb(200, 220, 255))
    .WithStroke(PdfColor.Blue, 1.5f)
    .WithFillOpacity(0.5f)   // 50% transparent fill
    .WithStrokeOpacity(0.8f)

StrokeStyle — line style and opacity:

StrokeStyle.Default
    .WithColor(PdfColor.Red)
    .WithWidth(2f)
    .Dashed()
    .WithOpacity(0.6f)

Multi-line text (DrawTextBox)

int overflowAt = canvas.DrawTextBox(
    text:        longText,
    x:           72,
    y:           100,
    width:       400,
    height:      600,
    style:       TextStyle.Default.WithSize(11),
    lineSpacing: 1.4f);

// If overflowAt < text.Length, paginate by passing text.Substring(overflowAt) to the next page.

Tables

var table = new PdfTable(new float[] { 120, 200, 80 })
    .WithHeaderBackground(PdfColor.FromRgb(70, 130, 180))
    .WithAlternateRowBackground(PdfColor.FromRgb(240, 240, 240))
    .WithBorder(PdfColor.Gray, 0.5f)
    .WithCellPadding(6f);

table.AddRow("Name", "Description", "Value");      // header
table.AddRow("Item A", "First item in the list", "1.00");
table.AddRow("Item B", "Second item", "2.50");

canvas.DrawTable(table, x: 72, y: 120, out float tableBottom);

Flow layout (PdfLayout)

PdfLayout builds a tree of elements and paginates the whole document before drawing, so content splits across pages correctly and headers and footers can say "Page 3 of 12". See Layout.md for the full guide.

var layout = PdfLayout.Begin(doc, PageSizes.A4)
    .WithMargins(54)
    .WithFooterText("Page {page} of {pages}");

layout.Bookmark("Summary")
      .Text("Quarterly report", TextStyle.Default.WithSize(20).WithBold())
      .Spans(s => s.Span("Revenue grew ").Span("12%", TextStyle.Default.WithBold()).Span(" — see ").Link("details", "https://example.com"))
      .Table(salesTable)           // splits between rows and repeats the header
      .Box(LayoutBoxStyle.Default.WithPadding(8).WithBackground(PdfColor.LightGray), b => b.Text(longNote));
layout.End().Save("report.pdf");

PDF/A conformance

PdfDocument.Create()
    .WithConformance(PdfConformance.PdfA2b)  // or PdfA1b, PdfA3b
    .WithFontRegistry(registry)              // embedded TrueType fonts required
    .AddPage(PageSizes.A4, canvas => { ... })
    .Save("archive.pdf");

PDF/A automatically sets the correct PDF version, embeds an sRGB ICC output intent, and writes the required XMP conformance claim. PDF/A and encryption cannot be combined.

Fonts

Register TrueType fonts and set up a fallback chain for glyphs the primary font lacks:

var registry = new FontRegistry()
    .AddFamily("NotoSans",
        regular: "/path/to/NotoSans-Regular.ttf",
        bold:    "/path/to/NotoSans-Bold.ttf")
    .AddFallback("NotoSans");   // used when the default font has no glyph for a character

PdfDocument.Create()
    .WithFontRegistry(registry)
    .AddPage(PageSizes.A4, canvas =>
    {
        canvas.DrawText("Hello", 72, 72,
            TextStyle.Default.WithFamily("NotoSans").WithSize(14));
    })
    .Save("output.pdf");

AddInstalledFonts(directory, includeSubfolders) registers every font in a folder under the family name it declares; add replaceExisting: true to replace families already registered. To add fonts to Majorsilence.Reporting's PDF export, see PdfFonts in the Reporting readme.

Text in any script draws when a font for it is registered (the fallback chain picks it per character).

Right-to-left and complex scripts

Every line goes through the Unicode Bidirectional Algorithm (UAX #9), so Hebrew and Arabic read right to left and a number or an English phrase inside them keeps its own order. WithRightToLeft() makes the paragraph right to left (combine it with TextAlignment.Right so x is the right edge); WithBidiOverride() lays every character out in that direction instead.

Joining scripts (Arabic) and the Brahmic scripts (Devanagari, Bengali, Tamil ...) also need shaping: contextual letter forms, ligatures, conjuncts, reordered vowel signs and mark positions come from the font's OpenType tables. The library has no shaper of its own, so that it keeps no native dependency; plug one in with WithTextShaper:

PdfDocument.Create()
    .WithFontRegistry(registry)
    .WithTextShaper(myShaper)       // an ITextShaper, e.g. over HarfBuzzSharp
    .AddPage(PageSizes.A4, canvas =>
        canvas.DrawText("\u0645\u0631\u062D\u0628\u0627", 520, 72,   // "marhaba" (hello)
            TextStyle.Default.WithFamily("NotoSansArabic").WithSize(16)
                .WithRightToLeft().WithAlignment(TextAlignment.Right)))
    .Save("arabic.pdf");

Without a shaper each character is drawn with the glyph the font's cmap gives it, in display order and with brackets mirrored: right for Hebrew, but Arabic letters then do not join. Shaped glyphs carry their text in the ToUnicode CMap, so the PDF's text can still be copied and searched. Majorsilence.Reporting's PDF export shapes with HarfBuzz.

Images

// JPEG or PNG (decoded in the core library: grayscale, RGB, palette, alpha; non-interlaced 8-bit).
var photo = PdfImage.FromBytes(File.ReadAllBytes("photo.jpg"));
canvas.DrawImage(photo, x: 72, y: 200, width: 200, height: 150);

// Or hand over pixels you decoded yourself.
var raw = PdfImage.FromRgba(pixels, pixelWidth: 64, pixelHeight: 64);

Identical images drawn on several pages are embedded once.

canvas.SaveState().ClipRoundedRectangle(72, 72, 200, 100, radius: 12);
canvas.DrawImage(photo, 72, 72, 200, 100);        // clipped to the rounded rectangle
canvas.RestoreState();

canvas.SaveState().Rotate(-15, cx: 300, cy: 300);  // clockwise degrees about a point
canvas.DrawText("DRAFT", 300, 300, TextStyle.Default.WithSize(48));
canvas.RestoreState();

canvas.AddBookmark("Chapter 1", y: 72);                          // outline entry
canvas.AddDestination("totals", x: 72, y: 400);                  // named destination
otherPage.AddInternalLink(72, 72, 100, 14, "totals");            // click to jump

BreakLines and GetLineHeight expose the wrapping DrawTextBox uses, for rich-text work.

canvas.AddLink(x: 72, y: 300, width: 150, height: 20, uri: "https://example.com");
canvas.AddTooltip(x: 72, y: 330, width: 150, height: 20, tooltip: "Hover text");

Merging documents

byte[] combined = new PdfMerger()
    .Add(File.ReadAllBytes("cover.pdf"))
    .Add(File.ReadAllBytes("body.pdf"))
    .WithTitle("Combined Report")
    .Merge();

File.WriteAllBytes("combined.pdf", combined);

Page sizes

Pre-defined sizes in PageSizes: A4, A3, Letter, Legal, Tabloid. Custom sizes via AddPage(width, height).

Document metadata

PdfDocument.Create()
    .WithTitle("Annual Report")
    .WithAuthor("Acme Corp")
    .WithSubject("Financial Summary")
    .Save("report.pdf");

PDF versions

Version Use case
PdfVersion.Pdf14 Maximum compatibility (default)
PdfVersion.Pdf17 PDF/A-2b and PDF/A-3b
PdfVersion.Pdf20 Latest spec; includes XMP metadata stream

Security companion

Password encryption and digital signatures are provided by the companion package Majorsilence.Pdf.Security. See that package's Readme for details.

Native AOT — verified, not just compatible

Majorsilence.Pdf targets net6.0 and above with IsAotCompatible enabled (which turns on the trim, AOT, and single-file analyzers) and has zero reflection in the drawing/rendering path. Every CI run publishes Examples/PdfAotSmokeTest as a self-contained Native AOT binary and actually executes it — text, tables, PdfLayout flow layout, AES password protection, PKCS#7 signing, and PDF merge all have to produce a structurally valid PDF or the build fails. This isn't just "it compiled without warnings"; it's "the binary ran and did the work."

Measured on Linux x64 (.NET 10, dotnet publish -r linux-x64 -p:PublishAot=true --self-contained true):

Metric Value
Published binary size ~6.7 MiB
Cold start, full smoke-test workload (3 documents + AES encryption + PKCS#7 signing + merge) ~70–150 ms
Native dependencies none
Runtime required on target machine none — the binary is self-contained

This makes Majorsilence.Pdf a good fit for AWS Lambda, Azure Functions, and other serverless or container workloads where cold-start latency and image size matter — no native library to bundle, no JIT warm-up.

Majorsilence.Pdf.Markdown (the Markdig-based extension package) publishes cleanly as Native AOT too, with the same zero-warning trim/AOT analyzer results.

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

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Holos.Reporting.Pdf:

Package Downloads
Holos.Reporting.Pdf.Security

Optional security extension for Majorsilence.Pdf. Adds AES-256 (PDF 2.0, R=6) and AES-128 (R=4) password protection, permission flags, and PKCS#7 digital signatures. AOT-compatible. Targets .NET Standard 2.0, .NET 6, .NET 8, and .NET 10. Fork of Majorsilence Reporting (Apache-2.0) with ReportViewer-compatible rendering of mixed run formatting and last-line overflow.

Holos.Reporting.RdlEngine

Cross-platform RDL/RDLC report rendering engine — run SQL Server Reporting Services (SSRS 2005) report definitions without a report server on Linux, macOS, Windows, and containers. SkiaSharp-based rendering, Native-AOT-compatible. Renders to PDF, HTML, MHTML, CSV, Excel, and images. Targets .NET 8 and .NET 10. Fork of Majorsilence Reporting (Apache-2.0) with ReportViewer-compatible rendering of mixed run formatting and last-line overflow.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
27.0.0-holos.2 64 11/13/2026
27.0.0-holos.1 60 11/13/2026