ToolUp.OpenXml.SvgRasterizer.Skia 0.23.0

Prefix Reserved
dotnet add package ToolUp.OpenXml.SvgRasterizer.Skia --version 0.23.0
                    
NuGet\Install-Package ToolUp.OpenXml.SvgRasterizer.Skia -Version 0.23.0
                    
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="ToolUp.OpenXml.SvgRasterizer.Skia" Version="0.23.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ToolUp.OpenXml.SvgRasterizer.Skia" Version="0.23.0" />
                    
Directory.Packages.props
<PackageReference Include="ToolUp.OpenXml.SvgRasterizer.Skia" />
                    
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 ToolUp.OpenXml.SvgRasterizer.Skia --version 0.23.0
                    
#r "nuget: ToolUp.OpenXml.SvgRasterizer.Skia, 0.23.0"
                    
#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 ToolUp.OpenXml.SvgRasterizer.Skia@0.23.0
                    
#: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=ToolUp.OpenXml.SvgRasterizer.Skia&version=0.23.0
                    
Install as a Cake Addin
#tool nuget:?package=ToolUp.OpenXml.SvgRasterizer.Skia&version=0.23.0
                    
Install as a Cake Tool

ToolUp.OpenXml.SvgRasterizer.Skia

A Skia-backed implementation of ToolUp.OpenXml's ISvgRasterizer seam.

ToolUp.OpenXml embeds an SVG figure vector-first: the SVG document goes into the package verbatim as an image/svg+xml part, referenced through the svgBlip blip extension that Word and PowerPoint have honoured since 2016. That embed needs no rasteriser at all, and the base package therefore ships none — it carries no rendering engine and no native dependency.

What a rasteriser adds is the optional PNG fallback part, which clients predating the extension render instead. This package produces it.

Install

dotnet add package ToolUp.OpenXml.SvgRasterizer.Skia

On Linux, additionally reference a SkiaSharp native asset package for the host — SkiaSharp ships the Windows and macOS natives itself, but not the Linux ones:

dotnet add package SkiaSharp.NativeAssets.Linux
# or, on a container with no fontconfig:
dotnet add package SkiaSharp.NativeAssets.Linux.NoDependencies

The NoDependencies variant needs no fontconfig, at the cost of the system font set — SVG <text> then renders with whatever fonts the image does carry. If your figures contain text, prefer the plain variant on Linux.

Use

open ToolUp.OpenXml
open ToolUp.OpenXml.SvgRasterizer.Skia

// Stateless — hold one for the lifetime of the deployment.
let rasterizer = SkiaSvgRasterizer.create ()

// The seam is asynchronous, so a figure that carries a fallback is built
// inside an async block: `Figures.svgWith` returns `Async<Block>`, not
// `Block`. That is the one shape change composing a rasteriser forces on a
// caller.
let renderChart (chartSvg: string) =
    async {
        // The figure carries both parts: the SVG verbatim, and a PNG fallback.
        let! figure = Figures.svgWith (Some rasterizer) chartSvg (Pixels(640, 360))
        return Emit.toBytes (DocModel.ofBlocks [ figure ])
    }

Passing None instead of Some rasterizer is not a degraded mode — it is the vector-only embed, and it is what a deployment that never installs this package gets. A rasteriser that fails returns Error and the figure embeds SVG-only; the caller never loses the picture over a missing fallback.

Behaviour

  • Width in, aspect preserved. Rasterize(svg, widthPx) takes one dimension; the height follows the SVG's own bounds, so a fallback can never be produced at a distorted aspect.
  • Transparent background. The fallback is the same picture as the vector part; an SVG that declares no background does not gain one on the way to a raster.
  • Failures are values. A malformed payload, an SVG with no positive drawing bounds, a non-positive width, or a width above the 20000-pixel ceiling all return Error with a human-readable reason. Nothing in the rasterisation path raises.
  • Native probe at construction. create touches Skia once and raises a message naming the missing native asset package if the runtime identifier has none — so an absent RID fails at composition, not part-way through a document emit.

Licensing

MIT throughout the rendering stack: Svg.Skia and its Svg.Model / Svg.Custom / Svg.SceneGraph / Svg.Animation siblings, SkiaSharp, and HarfBuzzSharp (text shaping). This package itself is Apache-2.0, like the rest of the SDK.

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.

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.23.0 39 9/23/2026