{"id":46743445,"url":"https://github.com/evolvedlight/typstsharp","last_synced_at":"2026-03-09T18:14:41.271Z","repository":{"id":324602813,"uuid":"1097789852","full_name":"evolvedlight/typstsharp","owner":"evolvedlight","description":"Typst binding for C#","archived":false,"fork":false,"pushed_at":"2026-02-01T16:48:35.000Z","size":92,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2026-02-19T00:51:28.836Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evolvedlight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-16T20:32:42.000Z","updated_at":"2026-02-01T16:46:24.000Z","dependencies_parsed_at":"2026-01-08T11:00:11.968Z","dependency_job_id":null,"html_url":"https://github.com/evolvedlight/typstsharp","commit_stats":null,"previous_names":["evolvedlight/typstsharp"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/evolvedlight/typstsharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedlight%2Ftypstsharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedlight%2Ftypstsharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedlight%2Ftypstsharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedlight%2Ftypstsharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evolvedlight","download_url":"https://codeload.github.com/evolvedlight/typstsharp/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedlight%2Ftypstsharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30306345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T17:35:44.120Z","status":"ssl_error","status_checked_at":"2026-03-09T17:35:43.707Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-09T18:14:37.235Z","updated_at":"2026-03-09T18:14:41.257Z","avatar_url":"https://github.com/evolvedlight.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typstsharp\n\nA .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.\n\n## Using\n\nA simple example:\n\n```csharp\n#:package typstsharp@0.0.8\n\nusing typstsharp;\n\nvar compiler = TypstCompiler.FromSource(\"= Hello World!\");\nvar result = compiler.Compile();\n\nvar file = result.Buffers[0];\nawait File.WriteAllBytesAsync(\"output.pdf\", file);\nConsole.WriteLine(\"PDF generated: output.pdf\");\n\n// Open the generated PDF file (works on Windows)\nSystem.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(\"output.pdf\") { UseShellExecute = true });\n```\n\nA more complicated example where we bulk generate PDFs:\n```csharp\n#:package typstsharp@0.0.8\n\nusing typstsharp;\n\nvar typstInput = \"\"\"\n#let (\n  first-name,\n  points-balance,\n) = sys.inputs\n\n#set page(header: align(\n  right + bottom,\n  text(\"Logo\"),\n))\n#set text(font: \"IBM Plex Sans\")\n\nHello *#first-name,*\n\nYou have accrued\n#underline[#points-balance]\nGlorboCorp Rewards Points\nlast year!\n\"\"\";\n\nvar compiler = TypstCompiler.FromSource(typstInput);\nDirectory.CreateDirectory(\"output\");\n\nvar people = new Dictionary\u003cstring, int\u003e\n{\n    [\"Alice\"] = 1200,\n    [\"Bob\"] = 850,\n    [\"Charlie\"] = 4300,\n};\n\nforeach (var (person, balance) in people)\n{\n    compiler.SetSysInputs(new Dictionary\u003cstring, string\u003e\n    {\n        [\"first-name\"] = person,\n        [\"points-balance\"] = balance.ToString(),\n    });\n\n    var result = compiler.Compile();\n\n    var file = result.Buffers[0];\n    await File.WriteAllBytesAsync($\"output/output{person}.pdf\", file);\n    Console.WriteLine($\"PDF generated: output{person}.pdf\");\n}\n\nSystem.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(\"output\") { UseShellExecute = true });\n```\n\n\nYou can easily use this inside of an ASP.Net Server (just ensure you lazy load and cache the TypstCompiler to reduce from 40ms to around 3ms for a normal compile).\n\n## Prerequisites\n\n- [.NET SDK 10.0](https://dotnet.microsoft.com/) – required to build the managed projects.\n- [Rust toolchain](https://www.rust-lang.org/tools/install) with `cargo` on your `PATH` – used to build the native `typst_core` cdylib.\n\n## Building\n\n```pwsh\n# from the repository root\n dotnet build typstsharp.sln\n```\n\nThe build will automatically:\n\n1. 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.\n2. Stage the produced native libraries under `obj/`.\n3. Add the libraries to the managed project's runtime assets so that `dotnet publish`/`dotnet pack` place the files under `runtimes/\u003crid\u003e/native/` in the final artifact.\n4. 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.\n\nYou can override the target runtimes by setting the `RustTargets` property (e.g., `dotnet build -p:RustTargets=win-x64`).\n\n## Verifying the CLI\n\n```pwsh\n# after a successful build\n dotnet run --project src/typstsharp.cli/typstsharp.cli.csproj\n```\n\nBecause the Rust binary is registered as a runtime asset, `typst_core.dll`/`libtypst_core.so` will appear beside the CLI executable automatically.\n\n## Notes\n\n- If you need to inspect the generated P/Invoke bindings, see `src/typstsharp/Bindings.g.cs` (created via `csbindgen` during the Rust build script).\n- 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevolvedlight%2Ftypstsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevolvedlight%2Ftypstsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevolvedlight%2Ftypstsharp/lists"}