SVG translated as PNG

Hello,
I’m having a problem. One of my svg is translated into PNG instead of EMF.
Here is a exemple
simple-test-4-aspose.zip (58.9 KB)

Am I missing an option ?

Best Regards

@rodrigue.leopold Actually SVG image is inserted into the document as SVG, but SVG images in MS Word always have PNG image fallback. If you unzip the output document, you will there is both PNG and SVG image representation inside.

Thanks for you answer but my problem is that, when I open the word, it’s the PNG that is shown and not the SVG. I can’t work on the picture.
I’m working with authors. They are writing documents with word and we process them to translate them in HTML. When we need to make changes to the HTML, I push the html in a word file and the authors fix the document and push it back to me, etc…
In this exemple, the author pushed an SVG file, and got a PNG back. That’s a problem.

My other problem, which is related to this, is that, when I look at the shape it says PNG, and finally, when the doc is saved as HTML, it’s an SVG that is created. I would like that the doc says EMF as it should to have coherence (or consistency) because I’m doing special treatments for EMF translations.

@rodrigue.leopold I have tested your scenario with the following simple code:

Document doc = new Document("C:\\Temp\\in.html");
doc.save("C:\\Temp\\out.docx", SaveFormat.DOCX);
    
Document doc1 = new Document("C:\\Temp\\out.docx");
doc1.save("C:\\Temp\\out.html");

And in the output HTML the image is SVG as expected. So it is not quite clear how to reproduce the problem.

The problem is that, when I translate back the docx to html, when I iterate over the shapes to make special treatments for SVG or EMF pictures, the shapes returns ImageType.PNG. It says PNG, but in the end it creates an SVG.
So your test is correct. But between the two transformations, why does the shape have a PNG type ?

To reproduce the problem, just print the shape types for doc1. You will se that it’s a PNG, and not an EMF.
To solve my problem, just tell me how I can detect, that the picture will be translated as SVG ?

@rodrigue.leopold

The image is inserted as SVG, not as PNG into the document. But, as I have already mentioned, in MS Word documents SVG images must have PNG fallback representation. Aspose.Words returns PNG type of the shape image, because fallback image is PNG. If take a look at the inner representation of the shape in the document, you can see the following:

<pic:blipFill>
	<a:blip r:embed="rId4" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
		<a:extLst>
			<a:ext uri="{96DAC541-7B7A-43D3-8B79-37D633B846F1}">
				<asvg:svgBlip xmlns:asvg="http://schemas.microsoft.com/office/drawing/2016/SVG/main" r:embed="rId5" />
			</a:ext>
		</a:extLst>
	</a:blip>
	<a:stretch>
		<a:fillRect />
	</a:stretch>
</pic:blipFill>

As you can see actual blip refers to rId4, which is a PNG image:

<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image1.png" />

But in the extensions there is svgBlip, which refers to rId5, which is the original SVG:

<Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image2.svg" />

I am afraid, currently there is no way to detect SVG shapes in the document programmatically.

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): WORDSNET-25611

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.

In the previous version (the 2021 version) it worked. The picture was an EMF . I found that bug by doing regression testing.
Thanks for your help.

@rodrigue.leopold It is not a bug. In older versions of Aspose.Words inserting SVG images was not supported. SVG images was converted to EMF metafile before insertion to preserve their vector nature. Currently Aspose.Words inserts SVG images just like MS Word does and they are not stored as EMF metafiles, but as SVG + PNG fallback image.

Is there a way to fall back to this old behaviour and insert an EMF ?

@rodrigue.leopold No, unfortunately, there is not way to insert SVG images as EMF anymore.