novolis-documents / getting-started.md
Getting started
One-column pages to Skia PDF
dotnetpdfdocumentsnovolis
Prerequisites
- .NET 10 (
net10.0) - NuGet sources: nuget.org + GitHub Packages (
https://nuget.pkg.github.com/Novolis-Platform/index.json) - Local multi-repo work: ProjectReference mode via
-p:NovolisUseProjectReferences=true(see platform-project-ref-mode)
Install
dotnet add package Novolis.Documents
dotnet add package Novolis.Documents.SkiaNovolis.Documents.Layout is pulled transitively by Skia; reference it directly only if you paginate without writing PDF.
First PDF (fluent)
using Novolis.Documents;
using Novolis.Documents.Skia;
var document = Document.Create("Harbor Notes")
.Meta(m => m.Author("Novolis").Publisher("Novolis-Platform"))
.Page(p => p
.Trade6x9()
.Header(h => h.Template("{title}").IncludeBody().UseChapterTitle())
.Footer(f => f.Template("{page} / {pages}").IncludeBody()))
.Body(b => b
.First(f => f.Lines("Trade sample"))
.Content(c => c
.Toc()
.Chapter("Arrival", ch => ch
.Paragraph("The river ran cold through Duckville harbor.")
.Table(t => t
.Headers("Cargo", "Tons")
.Row("Grain", "120")
.Rules(TableRuleStyle.Horizontal)
.HeaderBackground())))
.Last(l => l.Title("Colophon").Lines("End of sample.")))
.Build();
DocumentPdf.Write(document, @"C:\Users\frank\.novolis\artifacts\harbor-notes.pdf");First PDF (object initializer)
Mappers and generators can build PagedDocument without the fluent DSL:
using Novolis.Documents;
using Novolis.Documents.Skia;
var document = new PagedDocument
{
Meta = new DocumentMeta { Title = "Hello", Author = "Novolis" },
Setup = new PageSetup
{
Trim = TrimPresets.Inch6x9,
Margin = TrimPresets.DefaultMargin,
},
Typography = new Typography(),
IncludeCover = true,
Footer = new Footer
{
Template = "{page}",
IncludeBody = true, // First / Toc / Last default off (same as Header)
},
First = new FirstPage { Lines = ["Sample"] },
Body =
[
new HeadingBlock { Level = 1, Text = "One" },
new ParagraphBlock { Text = "Hello, document." },
],
};
DocumentPdf.Write(document, "hello.pdf");Dogfood samples
| App | Path | Purpose |
|---|---|---|
| HelloDocument | `d:\novolis\novolis-dogfooding\apps\documents\HelloDocument` | Full fluent book-style sample |
| HelloMarkdownPdf | `d:\novolis\novolis-dogfooding\apps\documents\HelloMarkdownPdf` | Markup → Documents → PDF |
dotnet run --project d:\novolis\novolis-dogfooding\apps\documents\HelloDocument\HelloDocument.csproj -p:NovolisUseProjectReferences=trueArtifact: C:\Users\frank\.novolis\artifacts\hello-document\hello-document.pdf
Build & test this repo
dotnet restore d:\novolis\novolis-documents\Novolis.Documents.slnx
dotnet build d:\novolis\novolis-documents\Novolis.Documents.slnx -p:NovolisUseProjectReferences=true
dotnet test d:\novolis\novolis-documents\tests\Novolis.Documents.Unit\Novolis.Documents.Unit.csproj -p:NovolisUseProjectReferences=trueNext reading
- authoring.md — fluent DSL reference
- header-footer.md — page numbers, chapter header, watermark
- blocks.md — tables, columns, images
- layout-and-pdf.md — pagination and PDF options