egoPdf

Coded PDFs, perfect on paper.

A .NET library family for millimetric PDF layout. Agent-friendly. Ruler-grade. Pure MIT.

C# code on the left transforming into a printed PDF on the right with ruler and pencil overlay.

Pixel-perfect PDFs in C#

Imperative control over every cell, every millimetre, with no PHP detour. SkiaSharp underneath for accurate font metrics; SourceLink and symbol packages for clean debugging.

  • The 14 PDF core fonts ship out of the box — no TTF needed for "Hello World".
  • Embed any TrueType with a single LoadFont call.
  • Output validates cleanly in Acrobat, Chrome and the major PDF viewers.
Diagram of an A4 page being carved into rows, columns and a titled panel with Row/Stack/Panel labels.

Layout that reads like the page it draws

Row, Stack and Panel compose a page without the x + width + gap arithmetic. The call site reads as the layout it produces.

var cols = pdf.Row(pdf.Bounds(), new[] { 2.0, 1.0 }, gap: 3);
pdf.Panel(cols[0], "DETAILS", brandStyle, content => {
    // body lives inside `content`,
    // state restored on return
});
A4 page split into a dark brand header band on top and a clean Markdown body with stylised paragraphs and a coral block-quote bar.

Markdown and ruler-grade drawing on the same page

Render CommonMark + GFM through EgoPDF.Markdown, drop into native code where the visual demands it. The shortcode extension is the bridge.

  • Headings, lists, code blocks, links, autolinks, quotes, images.
  • [[barcode]], [[image]], [[cta]], [[imagepair]] — each block shortcode dispatches to a handler you control.
  • Imperative header bands compose with Markdown bodies in the same FPdf instance.
Abstract geometric agent figure holding a printed A4 page next to a wooden ruler and pencil.

Friendly for humans and agents

Single-method primitives, scope helpers that auto-restore state, declarative styling records and a copy-pasteable recipe catalog. An LLM agent can derive everything it needs from the same shipping samples a developer reads.

  • using (pdf.PushState()) / PushPos() — mutate freely, revert on exit.
  • PanelStyle records capture frame + title looks as reusable data.
  • RECIPES.md indexes every pattern with pointers into the source samples.
  • SHA-256 visual baselines catch unintended drift between refactors.

Three packages, all MIT

EgoPDF.Generator

Core PDF engine with the layout primitives. Depends on SkiaSharp.

EgoPDF.Barcodes

Every 1D / 2D symbology through ZXing.Net, plus a ZPL II emulator.

EgoPDF.Markdown

CommonMark + GFM via Markdig, rendered through EgoPDF.Generator.

Ready to render?

See the live examples or grab the packages from NuGet.