Content displays abnormally after converting svg to image

Part of the content displays abnormally when I try to convert an SVG file to a JPG file use Aspose.SVG . I tried converting to PDF and it displayed normally.

The Screenshot

20240114174037.jpg (198.7 KB)

Version Info

Aspose.SVG for Net 23.12.0

Sample Code

void Main()
{
	string sourcePath= @"C:\Users\54390\Desktop\input.svg";
	string outputPath= @"C:\Users\54390\Desktop\output.jpg";

	var config = new Aspose.Svg.Configuration();
	var userAgentService = config.GetService<Aspose.Svg.Services.IUserAgentService>();
	userAgentService.CharSet = "utf-8";

	var format = Aspose.Svg.Rendering.Image.ImageFormat.Jpeg;
	var options = new Aspose.Svg.Saving.ImageSaveOptions(format);
	options.PageSetup.Sizing = Aspose.Svg.Rendering.SizingType.FitContent;
	Aspose.Svg.Converters.Converter.ConvertSVG(sourcePath, config, options, outputPath);
}

Input and Output File

Demo.zip (1.3 MB)

@sullivan

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SVGNET-317

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@sullivan

The abnormal display issue you’re encountering when converting an SVG file to a JPG using Aspose.SVG is due to the limitations of GDI+ in rendering some CFF (Compact Font Format) fonts, which are used in your document. GDI+ can sometimes struggle with complex font rendering, leading to the issues you’re experiencing.

To resolve this, we recommend using the Aspose.SVG.Drawing.SkiaSharp component. This component leverages SkiaSharp for rendering graphics and fonts, which provides better handling of such fonts compared to GDI+.

You can find the Aspose.SVG.Drawing.SkiaSharp component on NuGet at this link: [NuGet Gallery | Aspose.SVG.Drawing.SkiaSharp 24.1.0].

To use this component, you just need to add it to your project. Here’s the code snippet for activating the SkiaSharp-based drawing engine:

using Aspose.Svg.Drawing.SkiaSharp;

// Initialize SkiaSharp-based drawing engine
Aspose.Svg.Configuration.SetExtension(new SkiaModule());

By integrating this component, the SVG to JPG conversion should work correctly without the display issues you’ve been encountering. We’ve attached the file (SVGNET-317.jpeg) demonstrating the correct output using this approach for your reference.
SVGNET-317.jpeg (378.4 KB)

@asad.ali
I don’t find the class Aspose.Svg.Drawing.SkiaSharp.SkiaModule in Aspose.SVG for Net 24.1

@sullivan

You need to install this component from NuGet Pacakge Manager. You can use below command Package Manager Console:

dotnet add package Aspose.SVG.Drawing.SkiaSharp --version 24.1.0