Hello.
During the demo tests for Aspose.SVG and Skia rendering, I’ve stumbled upon the issue, that setting the correct page size seems to be inconsistent, if the viewbox is set up in SVG.
Let’s say I don’t use SkiaModule, then during the PNG export to get the size of the resulting image equal to SVG width and height, I use this code:
var width = _svgDocument.RootElement.Width.BaseVal.Value;
var height = _svgDocument.RootElement.Height.BaseVal.Value;
var options = new ImageRenderingOptions();
options.PageSetup.AnyPage.Size = new Size((int)width, (int)height);
And it works just fine. But should I add the
Configuration.SetExtension(new SkiaModule());
line at the beginning of the code, the resulting size is multiplied by the viewbox coefficient, so I have to divide by the value to get the needed result:
var width = _svgDocument.RootElement.Width.BaseVal.Value;
var height = _svgDocument.RootElement.Height.BaseVal.Value;
var matrix = _svgDocument.RootElement.GetScreenCTM();
var options = new ImageRenderingOptions();
options.PageSetup.AnyPage.Size = new Size((int)(width / matrix.A), (int)(height / matrix.D));
This seems counterintuitive, and could probably cause some performance issues during rendering.
Perhaps you can check out this issue, or guide me if I’m doing something wrong.
@AlexeiD
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-362
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.
The issues you have found earlier (filed as SVGNET-362) have been fixed in this update. This message was posted using Bugs notification tool by vdeviatov
@AlexeiD
The problem you experienced stems from how the page size settings interact with the resolution settings in pixels per inch (dpi). By default, when the page size is specified in pixels (px), Aspose.SVG automatically uses a resolution of 300 dpi. However, if the page size is set directly in pixels, the system adjusts to a standard display resolution of 96 dpi. Unfortunately, the SkiaSharp module did not inherit this behavior, leading to the inconsistencies you observed in the output size.
We have now addressed this discrepancy. The SkiaSharp module has been updated to align with the default resolution handling when page sizes are set in pixels. Additionally, We have included detailed comments in the page setup options to clarify the expected behavior for both vertical and horizontal resolution settings.
Thanks, I’ve tested the new version, everything works as expected.
@AlexeiD
It is nice to know that things are working as expected at your end. Please feel free to create a new topic in case you need further assistance.