Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A .NET 11.0 wrapper around the Typst 0.15 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.

For the latest changes, see our [Release Notes](RELEASENOTES.md).
Install from [NuGet](https://www.nuget.org/packages/typstsharp). For the latest changes, see our [Release Notes](https://github.com/evolvedlight/typstsharp/blob/develop/RELEASENOTES.md) or [GitHub Releases](https://github.com/evolvedlight/typstsharp/releases).

## Using

Expand Down Expand Up @@ -291,7 +291,7 @@ On Alpine / musl (`linux-musl-*`), musl's allocator reuses freed memory for late

## Supported Platforms & NuGet Packages

`typstsharp` ships as a small managed package that depends on per-architecture native runtime packages (similar to `SkiaSharp`):
[`typstsharp`](https://www.nuget.org/packages/typstsharp) ships as a small managed package that depends on per-architecture native runtime packages.

- `typstsharp.runtime.win-x64`
- `typstsharp.runtime.win-arm64`
Expand Down
4 changes: 4 additions & 0 deletions src/PackageMetadata.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<Version>0.0.1-typst0.15.0</Version>
<Authors>evolvedlight</Authors>
<PackageTags>typst;typesetting;pdf;rust</PackageTags>
<PackageProjectUrl>https://github.com/evolvedlight/typstsharp</PackageProjectUrl>
<RepositoryUrl>https://github.com/evolvedlight/typstsharp</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
</PropertyGroup>
</Project>
7 changes: 4 additions & 3 deletions src/typstsharp/TypstCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ public record TypstWarning(string Message);
/// </summary>
/// <param name="format">The output format (e.g., "pdf"). This parameter is currently not used by the underlying engine but is kept for future compatibility.</param>
/// <param name="ppi">The pixels per inch for the output. This parameter is currently not used by the underlying engine but is kept for future compatibility.</param>
/// <param name="pdfStandards">Optional PDF standard(s) to target (for example <c>"v-1.7"</c> or <c>"a-2b"</c>).</param>
/// <returns>A tuple containing a list of byte arrays for each page and a list of warnings.</returns>
public (List<byte[]> pages, List<TypstWarning> warnings) CompileToPages(string format = "pdf", float ppi = 144.0f, IEnumerable<string>? pdfStandards = null)
{
Expand Down Expand Up @@ -968,7 +969,7 @@ public PdfResult AsPdf()

/// <summary>
/// Represents the result of compiling a document to PDF format.
/// Supports implicit conversion to <see cref="byte[]"/>, <see cref="ReadOnlySpan{T}"/>, and <see cref="ReadOnlyMemory{T}"/>.
/// Supports implicit conversion to <c>byte[]</c>, <see cref="ReadOnlySpan{T}"/>, and <see cref="ReadOnlyMemory{T}"/>.
/// </summary>
public sealed record PdfResult(byte[] Bytes, IReadOnlyList<string> Warnings)
{
Expand Down Expand Up @@ -1138,7 +1139,7 @@ public Task SaveAsync(string path, int pageIndex = 0, CancellationToken cancella

/// <summary>
/// Represents the result of compiling a document to PNG format (one PNG image byte array per page).
/// Supports implicit conversion to <see cref="byte[]"/> (returning the primary page PNG bytes).
/// Supports implicit conversion to <c>byte[]</c> (returning the primary page PNG bytes).
/// </summary>
public sealed record PngResult(IReadOnlyList<byte[]> Pages, IReadOnlyList<string> Warnings) : IReadOnlyList<byte[]>
{
Expand All @@ -1156,7 +1157,7 @@ public sealed record PngResult(IReadOnlyList<byte[]> Pages, IReadOnlyList<string
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => new PageEnumerator<byte[]>(Pages);

/// <summary>
/// Implicitly converts the <see cref="PngResult"/> to <see cref="byte[]"/> of the primary PNG page.
/// Implicitly converts the <see cref="PngResult"/> to <c>byte[]</c> of the primary PNG page.
/// </summary>
public static implicit operator byte[](PngResult result) => result.Pages.Count > 0 ? result.Pages[0] : [];

Expand Down
12 changes: 10 additions & 2 deletions src/typstsharp/typstsharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<PackageId>typstsharp</PackageId>
<Description>A .NET wrapper for the Typst typesetting system.</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<DebugType>embedded</DebugType>

<NuspecFile>typstsharp.nuspec</NuspecFile>
<NuspecBasePath>$(MSBuildThisFileDirectory)</NuspecBasePath>
Expand Down Expand Up @@ -48,10 +51,15 @@
<Copy SourceFiles="@(HostNativeFile->'%(DestinationPath)')" DestinationFiles="@(HostNativeFile->'$(OutDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" Condition="@(HostNativeFile) != ''" />
</Target>

<Target Name="SetTypstSharpNuspecProperties" BeforeTargets="_GetOutputItemsFromPack;GenerateNuspec">
<Target Name="SetTypstSharpNuspecProperties"
BeforeTargets="_GetOutputItemsFromPack;GenerateNuspec"
DependsOnTargets="_InitializeNuspecRepositoryInformationProperties">
<PropertyGroup>
<_NuspecTags>$([System.String]::Copy('$(PackageTags)').Replace(';', ' '))</_NuspecTags>
<NuspecProperties>id=$(PackageId);version=$(PackageVersion);configuration=$(Configuration);authors=$(Authors);description=$(Description);tags=$(_NuspecTags);repositoryUrl=$(RepositoryUrl);license=$(PackageLicenseExpression)</NuspecProperties>
<_RepositoryCommit>$(RepositoryCommit)</_RepositoryCommit>
<_RepositoryCommit Condition="'$(_RepositoryCommit)' == ''">$(SourceRevisionId)</_RepositoryCommit>
<_RepositoryCommit Condition="'$(_RepositoryCommit)' == ''">$(GITHUB_SHA)</_RepositoryCommit>
<NuspecProperties>id=$(PackageId);version=$(PackageVersion);configuration=$(Configuration);authors=$(Authors);description=$(Description);tags=$(_NuspecTags);projectUrl=$(PackageProjectUrl);repositoryUrl=$(RepositoryUrl);repositoryCommit=$(_RepositoryCommit);license=$(PackageLicenseExpression)</NuspecProperties>
</PropertyGroup>
</Target>

Expand Down
6 changes: 5 additions & 1 deletion src/typstsharp/typstsharp.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
<version>$version$</version>
<authors>$authors$</authors>
<license type="expression">$license$</license>
<projectUrl>$projectUrl$</projectUrl>
<readme>README.md</readme>
<description>$description$</description>
<releaseNotes>$repositoryUrl$/releases/tag/$version$</releaseNotes>
<tags>$tags$</tags>
<repository type="git" url="$repositoryUrl$" />
<repository type="git" url="$repositoryUrl$" commit="$repositoryCommit$" />
<dependencies>
<group targetFramework="net10.0">
<dependency id="typstsharp.runtime.win-x64" version="[$version$]" exclude="Build,Analyzers" />
Expand All @@ -33,6 +35,8 @@
<files>
<file src="../../README.md" target="" />
<file src="bin/$configuration$/net10.0/typstsharp.dll" target="lib/net10.0/" />
<file src="bin/$configuration$/net10.0/typstsharp.xml" target="lib/net10.0/" />
<file src="bin/$configuration$/net11.0/typstsharp.dll" target="lib/net11.0/" />
<file src="bin/$configuration$/net11.0/typstsharp.xml" target="lib/net11.0/" />
</files>
</package>
Loading