Typst.Native
0.2.0
dotnet add package Typst.Native --version 0.2.0
NuGet\Install-Package Typst.Native -Version 0.2.0
<PackageReference Include="Typst.Native" Version="0.2.0" />
<PackageVersion Include="Typst.Native" Version="0.2.0" />
<PackageReference Include="Typst.Native" />
paket add Typst.Native --version 0.2.0
#r "nuget: Typst.Native, 0.2.0"
#:package Typst.Native@0.2.0
#addin nuget:?package=Typst.Native&version=0.2.0
#tool nuget:?package=Typst.Native&version=0.2.0
Typst.Native
.NET bindings for Typst, the modern markup-based typesetting system.
Typst.Native lets you compile Typst documents to PDF, SVG, and PNG directly from .NET — no CLI installation or external processes required.
Features
- Native performance: calls Typst's Rust core via P/Invoke (no WASM overhead)
- Cross-platform: ships pre-built native libraries for Windows, Linux, and macOS (x64 + ARM64)
- Zero external dependencies: everything is bundled in the NuGet package
- Idiomatic C# API:
TypstCompiler, diagnostics, streaming output
Quick Start
dotnet add package Typst.Native
using Typst.Native;
using var compiler = new TypstCompiler();
var result = compiler.Compile("Hello, *Typst* from .NET!");
if (result.IsSuccess)
{
byte[] pdf = result.ToPdf();
File.WriteAllBytes("output.pdf", pdf);
}
else
{
foreach (var diag in result.Diagnostics)
Console.Error.WriteLine(diag);
}
Supported Platforms
| Runtime | NuGet RID | CI Runner |
|---|---|---|
| Windows x64 | win-x64 |
windows-latest |
| Linux x64 | linux-x64 |
ubuntu-latest |
| Linux ARM64 | linux-arm64 |
ubuntu-24.04-arm |
| macOS x64 | osx-x64 |
macos-latest (cross-compile) |
| macOS ARM64 | osx-arm64 |
macos-latest |
Building from Source
Prerequisites
- .NET 8.0 SDK or later
- Rust toolchain (stable)
Build the native library
cd native/typst-ffi
cargo build --release
The shared library will be output to native/typst-ffi/target/release/.
Build the .NET solution
dotnet build
dotnet test
Note: To run tests locally, you need to first build the native library and place it in the appropriate
runtimes/{rid}/native/directory undersrc/Typst.Native.Runtime/.
Architecture
Typst.Native/
├── native/typst-ffi/ # Rust FFI crate — thin C API over Typst
├── src/
│ ├── Typst.Native/ # Managed C# wrapper (main NuGet: Typst.Native)
│ ├── Typst.Native.Runtime/ # Native binaries package (Typst.Native.Runtime)
│ └── Typst.Native.Tests/ # Unit & integration tests
└── .github/workflows/ # CI/CD pipelines
Packages
| Package | Description |
|---|---|
Typst.Native |
Managed wrapper — the package you reference |
Typst.Native.Runtime |
Pre-built native libraries for all platforms |
Contributing
Contributions are welcome! Please open an issue first to discuss what you'd like to change.
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes
- Push to the branch and open a Pull Request
License
This project is licensed under the MIT License.
Typst itself is licensed under the Apache License 2.0. See the Typst repository for details.
| Product | Versions 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 is compatible. 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. |
-
net8.0
- Typst.Native.Runtime (>= 0.2.0)
-
net9.0
- Typst.Native.Runtime (>= 0.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.