Typst.Renderer 0.1.0

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

Typst.Renderer

한국어

Production-oriented .NET 8 SDK for rendering Typst 0.14.2 and CeTZ 0.5.2 in-process. The package returns SVG, PNG, PDF, or premultiplied RGBA8 as managed memory. It never starts typst.exe, cetz-render, Node, or Sharp.

Packages

Reference one runtime package. It brings the exact matching managed package:

<PackageReference Include="Typst.Renderer.Native.win-x64" Version="0.1.0" />

Use Typst.Renderer.Native.linux-x64 on Linux x64. Native assets follow NuGet's runtimes/{rid}/native/ convention.

GUI integrations are layered so the native SDK stays independent from every UI framework:

  • Typst.Renderer.Core turns renderer results into display-ready RGBA documents and owns the shared render, zoom, layout, view-mode, and navigation behavior.
  • Typst.Renderer.Avalonia displays those documents with a reusable TypstView.
  • Typst.Renderer.Uno displays those documents with a reusable WinUI/Uno TypstView.
  • Typst.Renderer.WinForms provides a native Windows Forms TypstView with DPI-aware zooming and scrolling multi-page layout.
  • Typst.Renderer.Wpf displays the same documents in a reusable WPF TypstView.
  • Typst.Renderer.WinUI provides a reusable WinUI 3 TypstView on the current stable Windows App SDK. It targets net8.0-windows10.0.19041.0.
  • GUI adapters share one view/rendering contract; see GUI adapter contract for fitting, page modes, navigation, lifecycle, and demo requirements.

GUI samples

The primary desktop sample screenshots below use the same window size and render the same nine-page Serial protocol project from Typst.Renderer.Demo.Shared. The second Avalonia screenshot shows its additional live quotation workflow.

Avalonia
Avalonia sample rendering the Serial protocol demo
Avalonia — Dynamic quotation
Avalonia sample rendering the live dynamic quotation
Uno Platform
Uno sample rendering the Serial protocol demo
Windows Forms
Windows Forms sample rendering the Serial protocol demo
WPF
WPF sample rendering the Serial protocol demo
WinUI 3
WinUI 3 sample rendering the Serial protocol demo

Avalonia

Render through the common Core layer and assign the result to the Avalonia view:

using Typst.Renderer.Avalonia;
using Typst.Renderer.Core;

using var renderer = new TypstDocumentRenderer();
var document = await renderer.RenderSourceAsync(typstSource);

var view = new TypstView
{
    Document = document,
    Zoom = 1.0
};

Run the interactive editor and preview sample from the repository root:

dotnet run --project samples/Typst.Renderer.Avalonia.Sample
dotnet run --project samples/Typst.Renderer.Avalonia.Sample -- --demo live-quotation

The sample's demo selector is backed by Typst.Renderer.Demo.Shared. Its nine embedded examples are UI-independent in-memory projects, so every GUI demo can reuse the same catalog without copying files again. The Avalonia-only Dynamic quotation example also exposes editable recipient fields and automatically refreshes both the Typst source and rendered preview.

WPF

Typst.Renderer.Wpf targets net8.0-windows and has no third-party runtime dependency. Place its view in a WPF ScrollViewer for multi-page scrolling:

using Typst.Renderer.Core;
using Typst.Renderer.Wpf;

using var renderer = new TypstDocumentRenderer();
var document = await renderer.RenderSourceAsync(typstSource);

var view = new TypstView
{
    Document = document,
    Zoom = 1.0,
    PageSpacing = 24
};
var preview = new System.Windows.Controls.ScrollViewer { Content = view };

The adapter converts premultiplied RGBA pages to WPF's premultiplied BGRA format, preserves each page PPI, and sizes pages in device-independent pixels. Dispose the view to release its cached images and document reference deterministically.

Run the editable nine-demo WPF sample from the repository root:

dotnet run --project samples/Typst.Renderer.Wpf.Sample

Pass -- --software-rendering when a remote desktop or capture environment cannot record WPF's hardware-composited client area.

Uno Platform

Reference the UI adapter in addition to the native RID package:

<PackageReference Include="Typst.Renderer.Uno" Version="0.1.0" />
<PackageReference Include="Typst.Renderer.Native.win-x64" Version="0.1.0" />

The Uno adapter implements the shared ITypstDocumentView contract and delegates zoom fitting, page modes, navigation, and exact placement to TypstDocumentViewController. It converts premultiplied RGBA pages to WinUI's premultiplied BGRA layout; the adapter owns only Uno bitmap and visual resources:

using Typst.Renderer.Core;
using Typst.Renderer.Uno;

var view = new TypstView();
view.SetViewport(1200, 800);
using var renderController = new TypstRenderController(view);
await renderController.RenderSourceAsync(typstSource);
view.SetZoomMode(TypstZoomMode.FitWidth);
view.SetViewMode(TypstPageViewMode.ContinuousFacing);
view.MoveNext();

Run the desktop Uno editor and scrolling multi-page preview from the repository root. It uses the same nine Typst.Renderer.Demo.Shared examples as the Avalonia sample and exposes custom/width/page zoom, continuous/single/facing page modes, and previous/next navigation:

dotnet run --project samples/Typst.Renderer.Uno.Sample -f net8.0-desktop

Set TYPST_NATIVE_LIBRARY to a built typst_dotnet_native.dll when it is not available under artifacts/native/win-x64/ before building the sample. The verified targets are net8.0-desktop (Skia Desktop) and net8.0-windows10.0.26100 (Windows App SDK). The adapter package also contains the framework-neutral net8.0 Uno asset for other Uno heads.

Windows Forms

The Windows Forms adapter targets net8.0-windows and has no third-party runtime dependency. It copies Core's premultiplied RGBA pages into control-owned GDI+ premultiplied BGRA bitmaps, preserves alpha, and combines render PPI with the monitor DPI and Zoom when laying out pages:

using Typst.Renderer.Core;
using Typst.Renderer.WinForms;

using var renderer = new TypstDocumentRenderer();
var document = await renderer.RenderSourceAsync(typstSource);

var view = new TypstView
{
    Dock = DockStyle.Fill,
    Document = document,
    Zoom = 1.0,
    PageSpacing = 24
};

TypstView owns its converted bitmaps and disposes them when the document changes or the control is disposed. Its built-in scrolling surface paints only visible pages. Run the Windows Forms editor and multi-page preview from the repository root:

dotnet run --project samples/Typst.Renderer.WinForms.Sample

All GUI samples reuse all nine projects in Typst.Renderer.Demo.Shared, including multi-file imports, embedded SVG assets, and multi-page documents.

WinUI 3

TypstView implements ITypstDocumentView and delegates fitting, page modes, navigation, and exact page bounds to TypstDocumentViewController. The WinUI adapter owns only native image resources, UI dispatch, and scrolling:

using Typst.Renderer.Core;
using Typst.Renderer.WinUI;

var view = new TypstView
{
    ZoomMode = TypstZoomMode.FitWidth,
    ViewMode = TypstPageViewMode.ContinuousFacing,
    PageSpacing = 24
};
await view.SetDocumentAsync(document);
view.MoveNext();

The unpackaged x64 sample uses TypstRenderController, the shared nine-demo catalog, all fitting and page modes, navigation, and page status:

$env:TYPST_NATIVE_LIBRARY = 'C:\path\to\typst_dotnet_native.dll'
dotnet run --project samples/Typst.Renderer.WinUI.Sample -c Release

Memory rendering

using Typst.Renderer;

using var renderer = new TypstRenderer(new TypstRendererOptions
{
    PackageResolution = TypstPackageResolution.EmbeddedOnly
});

var project = new TypstProjectBuilder()
    .WithMainFile("charts/main.typ")
    .AddText("charts/main.typ", """
        #import "@preview/cetz:0.5.2": canvas, draw
        #import "data.typ": values
        #canvas({ draw.rect((0, 0), (values.at(0), 2), fill: blue) })
        """)
    .AddText("charts/data.typ", "#let values = (3, 5, 8)")
    .Build();

var result = renderer.RenderProject(project, new TypstRenderSettings
{
    Formats = [TypstOutputFormat.Pdf, TypstOutputFormat.Rgba],
    Ppi = 96
});

ReadOnlyMemory<byte> pdf = result.Artifacts.Single(x => x.Format == TypstOutputFormat.Pdf).Data;
using Stream pdfStream = result.Artifacts.Single(x => x.Format == TypstOutputFormat.Pdf).OpenRead();
await result.WriteToDirectoryAsync("rendered");

RenderFile, RenderSource, and RenderProject each have async counterparts. One renderer serializes calls. Multiple renderer instances may run in parallel. Cancellation stops waiting for an instance; it does not interrupt a Typst compilation that has already entered native code.

Project paths are normalized relative paths. Absolute paths, .., duplicates, and a missing text main file are rejected. Text and arbitrary binary files can be mixed, so in-memory images and imported .typ modules need no temporary files.

Configuration

System font discovery is off by default. FontPaths and MemoryFonts are validated when the renderer is created. BaseDirectory supplies fallback files for relative imports. Set RestrictToDirectory for untrusted documents; it becomes the native filesystem root.

Package resolution always checks embedded CeTZ 0.5.2 and oxifmt 1.0.0 first:

  • CacheThenNetwork: local Typst cache, then the Typst package service.
  • CacheOnly: local cache with no download.
  • EmbeddedOnly: embedded packages only.

NativeLibraryPath is intended for development and diagnostics. Normal NuGet consumers rely on RID assets. Handles are owned by SafeHandle; Rust-owned strings and result buffers are copied and released before public results return.

Build and test

cargo test --locked
cargo build --release --locked
New-Item -ItemType Directory -Force artifacts/native/win-x64 | Out-Null
Copy-Item target/release/typst_dotnet_native.dll artifacts/native/win-x64/
dotnet test -c Release
dotnet pack src/Typst.Renderer.Wpf/Typst.Renderer.Wpf.csproj -c Release -o artifacts/packages
dotnet build samples/Typst.Renderer.WinUI.Sample -c Release
dotnet pack src/Typst.Renderer/Typst.Renderer.csproj -c Release -o artifacts/packages
dotnet pack src/Typst.Renderer.WinForms/Typst.Renderer.WinForms.csproj -c Release -o artifacts/packages
dotnet pack src/Typst.Renderer.Native.win-x64/Typst.Renderer.Native.win-x64.csproj -c Release -o artifacts/packages
./eng/pack-and-verify.ps1 -Rid win-x64

The repository directly links Typst, CeTZ, and oxifmt in its Rust cdylib; it does not depend on the cetz-renderer repository at build time or runtime.

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.
  • net8.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Typst.Renderer:

Package Downloads
Typst.Renderer.Native.linux-x64

Linux x64 native runtime for Typst.Renderer

Typst.Renderer.Core

UI-neutral document rendering layer for Typst.Renderer

Typst.Renderer.Native.win-x64

Windows x64 native runtime for Typst.Renderer

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 37 8/12/2026