Getting Started

Install FolioPDF, create your first PDF, and explore the three entry points of the API.

Installation

Add FolioPDF to your project via the .NET CLI or the NuGet Package Manager:

dotnet add package FolioPDF

Or in your .csproj:

<PackageReference Include="FolioPDF" Version="2026.4.0" />

Requirements

RequirementDetails
Frameworks.NET 8 (LTS), .NET 9, .NET 10 (LTS)
PlatformsWindows x64, Linux x64
DependenciesNone — zero managed runtime dependencies

FolioPDF bundles all native binaries (Skia, PDFium, qpdf) inside the NuGet package. No separate installs, no system libraries, no browser engine.

Hello World

Create a minimal PDF with a single page:

using FolioPDF.Fluent;
using FolioPDF.Helpers;

Document.Create(doc =>
{
    doc.Page(page =>
    {
        page.Size(PageSizes.A4);
        page.Margin(50);
        page.Content().Text("Hello from FolioPDF!").FontSize(24);
    });
}).GeneratePdf("hello.pdf");

This produces a single-page A4 PDF with 50-point margins and a 24pt text line. The file is written to hello.pdf in the working directory.

Three Entry Points

FolioPDF has three primary APIs, each designed for a different workflow:

Entry PointPurposeBackend
Document.Create(...) Generate new PDFs from layout code Skia (rendering engine)
PdfEditor.Open(...) Edit existing PDFs — metadata, merge, encrypt, stamp, compress PDFium + qpdf
PdfiumDocument.Load(...) Inspect PDFs — extract text, render pages, read form fields PDFium

Generate a PDF

Use Document.Create to build a document from scratch with the fluent layout engine:

Document.Create(doc =>
{
    doc.Page(page =>
    {
        page.Size(PageSizes.A4);
        page.Margin(50);

        page.Header().Text("Invoice #1042").FontSize(24).Bold();

        page.Content().Column(col =>
        {
            col.Spacing(10);
            col.Item().Text("Thank you for your purchase.");
            col.Item().Table(table =>
            {
                table.ColumnsDefinition(c =>
                {
                    c.ConstantColumn(200);
                    c.RelativeColumn();
                    c.ConstantColumn(80);
                });
                table.Cell().Text("Item").Bold();
                table.Cell().Text("Description").Bold();
                table.Cell().Text("Price").Bold();
                table.Cell().Text("Widget Pro");
                table.Cell().Text("Premium widget with extended warranty");
                table.Cell().Text("$49.99");
            });
        });

        page.Footer().AlignCenter().Text(t =>
        {
            t.Span("Page ");
            t.CurrentPageNumber();
            t.Span(" of ");
            t.TotalPages();
        });
    });
}).GeneratePdf("invoice.pdf");

Edit an existing PDF

Use PdfEditor.Open to chain operations on an existing file:

PdfEditor.Open("input.pdf")
    .SetTitle("Annual Report 2026")
    .SetAuthor("TrueSpar")
    .AddBookmark("Introduction", pageIndex: 0)
    .RedactText("SSN 123-45-6789")
    .StampText(new TextStamp("CONFIDENTIAL") { Opacity = 0.3f })
    .Compress(new CompressionOptions { ImageQuality = 65 })
    .Encrypt(new Encryption256Bit { OwnerPassword = "secret" })
    .Save("output.pdf");

Inspect a PDF

Use PdfiumDocument.Load to read properties, extract text, or render pages:

using var doc = PdfiumDocument.Load(File.ReadAllBytes("report.pdf"));

Console.WriteLine($"Pages: {doc.PageCount}");
Console.WriteLine($"Title: {doc.GetMetadata().Title}");

using var page = doc.GetPage(0);
string text = page.ExtractText();
byte[] png = page.RenderToPng(dpi: 200);

Generate and post-process in one chain

Use PdfEditor.Create to generate a new PDF and immediately encrypt, compress, or linearize it — no intermediate files:

PdfEditor.Create(doc =>
{
    doc.Page(page =>
    {
        page.Size(PageSizes.A4);
        page.Content().Text("Confidential Report").FontSize(20).Bold();
    });
})
.SetTitle("Q1 Report")
.Encrypt(new Encryption256Bit { OwnerPassword = "finance-2026" })
.Linearize()
.Save("q1-report.pdf");

Output Options

Every document can be output in multiple formats:

var document = Document.Create(doc => { /* ... */ });

// PDF
document.GeneratePdf("output.pdf");           // file
document.GeneratePdf(stream);                  // stream
byte[] bytes = document.GeneratePdf();          // bytes

// SVG (one string per page)
IReadOnlyList<string> svgs = document.GenerateSvg();

// Images
var images = document.GenerateImages(new ImageGenerationSettings
{
    ImageFormat = ImageFormat.Png,
    RasterDpi = 300
});

Next Steps