We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Save image in SVG format

Hello,


Is it possible using Aspose.Words.dll to save an image in svg format?
My code is the following :

Aspose.Words.Document document = new Aspose.Words.Document(sourceFileName);
NodeCollection shapes = document.GetChildNodes(NodeType.Shape, true);

List images = new List();

//add the shapes
foreach (Shape shape in shapes)
{
if (shape.HasImage)
images.Add(shape.ImageData);
}
foreach (IImageData image in images)
{
image.Save(“something.svg”) /// it is not working .
}

We have a license only for Aspose.Words.
If not possible with this library what else should we purchase ?
I want to achieve something like the upper code.


Thank you

Hi,


Thanks for your inquiry. You can import image into an empty ‘Document’ instance and convert that document to SVG format. For example, please see the following code:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

Shape img = builder.InsertImage(MyDir + "Aspose.Words.jpg");

Document emptyDoc = new Document();

Shape importedImg = (Shape)emptyDoc.ImportNode(img, true);

DocumentBuilder builderEmptyDoc = new DocumentBuilder(emptyDoc);

builderEmptyDoc.InsertNode(importedImg);

emptyDoc.Save(MyDir + @“out.svg”, SaveFormat.Svg);


I hope, this helps.

Best regards,