typstsharp 0.0.5
See the version list below for details.
dotnet add package typstsharp --version 0.0.5
NuGet\Install-Package typstsharp -Version 0.0.5
<PackageReference Include="typstsharp" Version="0.0.5" />
<PackageVersion Include="typstsharp" Version="0.0.5" />
<PackageReference Include="typstsharp" />
paket add typstsharp --version 0.0.5
#r "nuget: typstsharp, 0.0.5"
#:package typstsharp@0.0.5
#addin nuget:?package=typstsharp&version=0.0.5
#tool nuget:?package=typstsharp&version=0.0.5
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
cargoon yourPATH– used to build the nativetypst_corecdylib.
Building
# from the repository root
dotnet build typstsharp.sln
The build will automatically:
- Run
cargo build --releaseonsrc/typst_corefor each target runtime identifier (RID). By default, this includeswin-x64,linux-x64, and others. For local debug builds, it only builds for the host architecture. - Stage the produced native libraries under
obj/. - Add the libraries to the managed project's runtime assets so that
dotnet publish/dotnet packplace the files underruntimes/<rid>/native/in the final artifact. - 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 viacsbindgenduring the Rust build script). - The native Rust layer is responsible for memory management of the Typst world. The
TypstCompilerclass isIDisposableand should be properly disposed to release native resources.
| Product | Versions 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. |
-
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 |