SVG as Image improperly rendered as bitmap

When importing a SVG as an Image, its inserted into the PDF as a raster image with bad compression as well as replacing transparency with a white background. How do I get it to insert it as a vector image drawing?

double originalWidth = 0, originalHeight = 0, ratioX = 1, ratioY = 1, ratio = 1;

//Using SVG Nuget Package to accurately read SVG dimensions
//and to change them
//https: //github.com/vvvv/SVG
SvgDocument svgDocument = Svg.SvgDocument.Open(imagePath);
originalWidth = svgDocument.Width;
originalHeight = svgDocument.Height;

//aspect ratios
ratioX = maxWidth / originalWidth ?? 1;
ratioY = maxHeight / originalHeight ?? 1;

//smallest ratio wins
ratio = Math.Min(ratioX, ratioY);

float newWidth = (float)Math.Ceiling(originalWidth * ratio);
float newHeight = (float)Math.Ceiling(originalHeight * ratio);

svgDocument.Width = new Svg.SvgUnit((float)newWidth);
svgDocument.Height = new Svg.SvgUnit((float)newHeight);

var svg = new Image
{
   FileType = ImageFileType.Svg,
   IsInLineParagraph = true,

   // new height and width
   FixWidth = newWidth,
   FixHeight = newHeight,
   IsApplyResolution = true
};

var stream = new MemoryStream();
svgDocument.Write(stream);

svg.ImageStream = stream;

return svg;

I would have uploaded the SVG but your forum blocks that filetype.

Aspose.PDF for .NET
Version 19.1.0

@dirq

Thanks for contacting support.

You may please add your SVG Image to ZIP Archive and share it with us. We will test the scenario in our environment and address it accordingly.

leaders-edge-logo.zip (2.1 KB)
Here you go. Thank you.

@dirq

Please also share the values of maxWidth and maxHeight variables used in your above shared code snippet.

double? maxHeight = 60;
double? maxWidth = null;

@dirq

Thanks for providing requested information.

We have tested the scenario in our environment and were able to replicate the issue. We have logged it as PDFNET-45879 in our issue tracking system for the sake of detailed investigation. We will further look into details of the issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Still an issue even with the latest version, 21.9.0

       var icon = new Image
        {
            File = speciesRightTagPath,
            FileType = ImageFileType.Svg,
            FixWidth = 284,
            FixHeight = 96,
            IsApplyResolution = false,
            ImageScale = 1,
        };
        FloatingBox iconBox = new FloatingBox();
        iconBox.Paragraphs.Add(icon);
        iconBox.VerticalAlignment = VerticalAlignment.Center;
        iconBox.Left = DocConfig.PageWidth - DocConfig.TrimBoxOffset - icon.FixWidth;
        iconBox.Top = box.Top - topMargin;

        box.Paragraphs.Add(iconBox);

SVG file (zipped)
petcare-right-header-area.zip (1.7 KB)

@dirq

We really apologize for the inconvenience. The earlier logged ticket could not get resolved due to which you are experiencing same issue in the 21.9 version of the API. We have logged another ticket as PDFNET-50758 in our issue management system for the recent case. We will surely work on resolving the issue and let you know as soon as it is fixed. Please give us some time.

We again apologize for the delay and the inconvenience.

What’s the status of this issue?

I’ve reviewed version 23.1.1 and the SVG images are still being improperly embedded within the document.

We’re evaluating the Aspose.Pdf license for an upgrade and this would hider us from moving forward.

@radleta8

We are afraid that the ticket(s) could not get resolved due to other pending issues in the queue. However, your concerns have been recorded and we will surely inform you once we make some progress in this regard. We apologize for the inconvenience.