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

Free Support Forum - aspose.com

How can i convert docx to SVG and output as MemoryStream?

i keep getting this error with the following code:

// create input stream with docx byte array
var inputStream = new MemoryStream(data);
var outputStream = new MemoryStream();

var doc = new Document(inputStream);


I just want the converter to convert the docx to SVG and send that as a byte[] back. How can i accomplish this with Aspose.Words?

Our end goal with this code is to convert to a format that will display properly in all devices and browsers using an Iframe.

<pre _ngcontent-c46="" class=“log-stream bottom-logs” id=“log-stream” tabindex=“1” style=“box-sizing: border-box; overflow: scroll; font-family: Consolas, “Lucida Console”, “Courier New”, monospace; font-size: 12px; padding: 5px; margin: 0px 25px 10px; line-height: 1.42857; color: rgb(51, 51, 51); word-break: normal; word-wrap: normal; background-color: rgb(242, 242, 242); border: 1px solid rgb(216, 225, 230); border-radius: 0px; height: 254.716px;”>VG. Aspose.Words: Resource file(s) cannot be written to disk. When saving the document to a stream either ResourceFolder should be specified or ExportEmbeddedImages, ExportEmbeddedFonts, ExportEmbeddedCss, and ExportEmbeddedSvg should be set or custom streams should be provided via ResourceSavingCallback.

Hi Shayan,

Thanks for your inquiry. We have tested the scenario with a sample DOCX file using Aspose.Words for .NET 17.6 and unable to notice the reported issue. Please share your sample input file here, we will look into it and will guide you accordingly.

Best Regards,

The input file we used contained embedded images and in some cases embedded documents. Does Aspose support these types of docx files? It seems as though this is not supported and the method is looking for a folder to store the sub images. However we want the method to ignore the resource folder and we want to return the file in a response body.

Attached is a simple docx file with an embedded image. This file will not be parsed and an error will be thrown. Is there a way to bypass the logic for saving to disk and simply output the parsed file as a stream?

Hi Shayan,

Thanks for sharing your source document. Please check following code snippet, it will help you to accomplish the task. When saving SVG with images into stream, you need to use ExportEmbeddedImages option for the purpose.

MemoryStream input = new

MemoryStream output = new MemoryStream();

var doc1 = new Document(input);

SvgSaveOptions option = new SvgSaveOptions();

option.ExportEmbeddedImages = true;


File.WriteAllBytes("D:/Downloads/DocImage.svg", ms.ToArray());

Best Regards,

Thank you very much!

Hello ,

I got the SVGs to display but on mobile devices the font seems to be clustering close together. how can i overcome this?

Hi Shayan,

Thanks for you inquiry. I have tested a simple SVG file with File Viewer for Android Application and unable to notice the reported issue. It seems it is device/application specific issue. We will appreciate it if you please try it on some other device/application and share the results. However, if the issue persist then please share following details. We will further look into the issue and will guide you accordingly.

  • Sample Problematic SVG
  • Sample SVG, that works fine
  • Mobile details/OS
  • Application to view SVG file

Best Regards,

1 Like