Conversion from SVG to DXF and SVG to PNG generates incorrect line

Hello,

We converted the following SVG file to DXF and PNG and it returns incorrect line crossing through the object.

The line is marked in this image from the resulting DXF file : AddedLineIssue.png (7.5 KB) and the conversion code is added below.

The SVG image and the resulting DXF and PNG has been attached as a zip file:
ResultingPNGAndDXF.zip (5.4 KB)

We are using Aspose.Imaging version 24.2.0 but we observed that the problem persists on the latest version 24.6.0 also.

Could you please help us in resolving this issue?

Thank you,
Victor

namespace Conversion
{
    using Aspose.Imaging;
    using Aspose.Imaging.FileFormats.Svg;
    using Aspose.Imaging.ImageOptions;

    public static class ImageConverter
    {
        private static readonly float Ratio = 71.6f;

        public static byte[] ConvertSvgToDxf(string svgInput, bool addBorder)
        {
            using (var stream = GenerateStreamFromString(svgInput))
            {
                using (var image = Image.Load(stream))
                {
                    ImageOptionsBase exportOptions = new DxfOptions
                    {
                        TextAsLines = false,
                        ConvertTextBeziers = false
                    };

                    if (image is VectorImage)
                    {
                        using (VectorRasterizationOptions rasterizationOptions = new SvgRasterizationOptions())
                        {
                            rasterizationOptions.PageWidth = image.Width / Ratio;
                            rasterizationOptions.PageHeight = image.Height / Ratio;
                            
                            rasterizationOptions.BackgroundColor = !addBorder ? Color.Empty : Color.LightGray;

                            exportOptions.VectorRasterizationOptions = rasterizationOptions;
                        }
                    }

                    using (MemoryStream outputStream = new MemoryStream())
                    {
                        image.Save(outputStream, exportOptions);
                        return outputStream.ToArray();
                    }
                }
            }
        }

        public static byte[] ConvertSvgToPng(string svgInput)
        {
            using var stream = GenerateStreamFromString(svgInput);
            using var image = (SvgImage) Image.Load(stream);
            
            var pngOptions = new PngOptions();

            if (image != null)
            {
                var rasterizationOptions = new SvgRasterizationOptions
                {
                    PageWidth = image.Width,
                    PageHeight = image.Height
                };

                pngOptions.VectorRasterizationOptions = rasterizationOptions;
            }

            using var outputStream = new MemoryStream();
            
            image?.Save(outputStream, pngOptions);
            
            return outputStream.ToArray();
        }

        private static Stream GenerateStreamFromString(string s)
        {
            var stream = new MemoryStream();
            var writer = new StreamWriter(stream);
            writer.Write(s);
            writer.Flush();
            stream.Position = 0;
            return stream;
        }
    }
}

@Victor.Ionescu Hello! We will investigate this issue and provide you with the results as soon as possible. Thank you for your patience.

@Alexey.Karpenko Thank you and we are looking forward for the results!

Have a great day,
Victor

@Victor.Ionescu
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): IMAGINGNET-7210

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.

1 Like