typstsharp 0.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package typstsharp --version 0.0.5
                    
NuGet\Install-Package typstsharp -Version 0.0.5
                    
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="typstsharp" Version="0.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="typstsharp" Version="0.0.5" />
                    
Directory.Packages.props
<PackageReference Include="typstsharp" />
                    
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 typstsharp --version 0.0.5
                    
#r "nuget: typstsharp, 0.0.5"
                    
#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 typstsharp@0.0.5
                    
#: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=typstsharp&version=0.0.5
                    
Install as a Cake Addin
#tool nuget:?package=typstsharp&version=0.0.5
                    
Install as a Cake Tool

typstsharp

A .NET 10.0 wrapper around the Typst rendering stack. The managed layer in src/typstsharp calls into the Rust typst_core crate via P/Invoke and exposes convenient helpers for C# consumers plus a simple CLI.

Prerequisites

  • .NET SDK 10.0 – required to build the managed projects.
  • Rust toolchain with cargo on your PATH – used to build the native typst_core cdylib.

Building

# from the repository root
 dotnet build typstsharp.sln

The build will automatically:

  1. Run cargo build --release on src/typst_core for each target runtime identifier (RID). By default, this includes win-x64, linux-x64, and others. For local debug builds, it only builds for the host architecture.
  2. Stage the produced native libraries under obj/.
  3. Add the libraries to the managed project's runtime assets so that dotnet publish/dotnet pack place the files under runtimes/<rid>/native/ in the final artifact.
  4. For local development, the native binary for the host architecture is copied to the output directory of any project referencing typstsharp, ensuring it's available for debugging.

You can override the target runtimes by setting the RustTargets property (e.g., dotnet build -p:RustTargets=win-x64).

Verifying the CLI

# after a successful build
 dotnet run --project src/typstsharp.cli/typstsharp.cli.csproj

Because the Rust binary is registered as a runtime asset, typst_core.dll/libtypst_core.so will appear beside the CLI executable automatically.

Usage

Here's a minimal example of how to use typstsharp to compile a document:

using typstsharp;
using System.IO;

// The Typst source code
var input = """
    #let title = sys.inputs.title
    = Hello, #title!
    """;

// Create a compiler instance
using var client = new TypstCompiler(input);

// Set system inputs, which are accessible from the Typst script
var sysInputs = new Dictionary<string, object>
{
    { "title", "World" }
};
client.SetSysInputs(sysInputs);

// Compile the document
var output = client.Compile();

// Save the output to a file
File.WriteAllBytes("output.pdf", output.Buffers[0]);

Notes

  • If you need to inspect the generated P/Invoke bindings, see src/typstsharp/Bindings.g.cs (created via csbindgen during the Rust build script).
  • The native Rust layer is responsible for memory management of the Typst world. The TypstCompiler class is IDisposable and should be properly disposed to release native resources.
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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.14.2.1 92 1/8/2026
0.14.2 247 12/19/2025
0.14.1 414 12/11/2025
0.0.8 192 11/25/2025
0.0.7 181 11/25/2025
0.0.6 193 11/24/2025
0.0.5 395 11/18/2025
0.0.3-typst0.14.0 357 11/18/2025
0.0.2-typst0.14.0 364 11/18/2025
0.0.1-typst0.14.0-preview.38 44 1/7/2026