Aspose.SVG.Drawing.SkiaSharp – Enhanced SVG Drawing and Conversion

Aspose.SVG.Drawing.SkiaSharp is a complete Aspose.SVG for .NET build that uses SkiaSharp for drawing and rendering. It provides the Aspose.SVG document, DOM, conversion, and rendering APIs in a package intended for applications that target Windows, Linux, or macOS.

Starting with Aspose.SVG for .NET 25.5, this package is no longer an add-on to Aspose.SVG. It is a self-contained build. Reference Aspose.SVG.Drawing.SkiaSharp as the Aspose.SVG package for the project; do not add an extension module or call SetExtension(new SkiaModule()).

When to Use the SkiaSharp Build

Use Aspose.SVG.Drawing.SkiaSharp when an application needs:

The standard Aspose.SVG package depends on System.Drawing.Common. Microsoft identifies System.Drawing.Common as Windows-specific starting with .NET 6 and documents that, from .NET 7, it cannot be re-enabled on non-Windows operating systems.

Install Aspose.SVG.Drawing.SkiaSharp

Install the Aspose.SVG.Drawing.SkiaSharp NuGet package instead of installing the standard Aspose.SVG package together with a SkiaSharp add-on.

For a PackageReference project, add the package with the version selected for your application:

1<ItemGroup>
2  <PackageReference Include="Aspose.SVG.Drawing.SkiaSharp" Version="<version>" />
3</ItemGroup>

The package targets .NET Standard 2.0. For framework and platform details, see System Requirements.

Convert SVG to PNG with the SkiaSharp Build

After the SkiaSharp build is referenced, use the standard Aspose.SVG API. No rendering-module registration is required.

 1using System.IO;
 2using Aspose.Svg;
 3using Aspose.Svg.Converters;
 4using Aspose.Svg.Saving;
 5
 6// Load the source SVG document
 7using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "source.svg")))
 8{
 9    // PNG is the default output format for ImageSaveOptions
10    ImageSaveOptions options = new ImageSaveOptions();
11
12    // Render the SVG document to a PNG image through the SkiaSharp build
13    Converter.ConvertSVG(document, options, Path.Combine(OutputDir, "result.png"));
14}

For additional image formats and rendering settings, see Convert SVG to Images in C#.

Conversion, Rendering, and SVG Output

With Aspose.SVG.Drawing.SkiaSharp, applications can render SVG content to:

Applications can also save edited or generated SVG document content as SVG or SVGZ. Rendered output can depend on fonts, external resources, effects, and rendering settings. Before deploying a rendering service, review SVG Rendering Quality and Output Consistency.

Linux Native Assets

Linux deployments using Aspose.SVG.Drawing.SkiaSharp require native Skia binaries. Published Aspose.SVG guidance lists the packages below; check that the selected package matches the SkiaSharp version, Linux distribution, and CPU architecture used by your application:

Deploy any fonts required by the SVG documents along with the application. Missing fonts can change text layout and the appearance of generated PDFs or images.

Migrate from the Previous Add-on Model

Projects built with versions before 25.5 may reference both Aspose.SVG and Aspose.SVG.Drawing.SkiaSharp and activate Skia rendering in code:

1Aspose.Svg.Configuration.SetExtension(new SkiaModule());

For Aspose.SVG for .NET 25.5 and later:

  1. Replace the previous dual-package setup with a reference to Aspose.SVG.Drawing.SkiaSharp.
  2. Remove calls to Aspose.Svg.Configuration.SetExtension(new SkiaModule()).
  3. Rebuild and test the rendered output required by the application.

The Aspose.SVG for .NET 25.5 release notes describe this package change and the related rendering API update.

FAQ

1. What is SkiaSharp?
SkiaSharp is an open-source 2D graphics API, stemming from Google’s Skia library. It is renowned for its high-quality rendering capabilities. By availing advanced graphics features and APIs, SkiaSharp is perfect for mobile apps, games, and even server applications.

2. Should a new cross-platform project install both Aspose.SVG and Aspose.SVG.Drawing.SkiaSharp?
No. For Aspose.SVG for .NET 25.5 and later, Aspose.SVG.Drawing.SkiaSharp is the complete Aspose.SVG build that uses SkiaSharp rendering. Install it as the Aspose.SVG package for a project that needs this rendering backend.

3. Does switching to the SkiaSharp build change the code that converts SVG files?
For high-level operations such as Converter.ConvertSVG(...), use the same Aspose.SVG API after referencing the SkiaSharp build. The migration change is to remove the former SetExtension(new SkiaModule()) activation call and test the output important to the application.

4. Why can a Linux container still need additional packages after installing Aspose.SVG.Drawing.SkiaSharp?
The .NET package uses native Skia binaries at runtime. A Linux container must provide native assets compatible with its distribution, CPU architecture, and SkiaSharp version. It may also need fonts used by the SVG documents being rendered.