0

I have an Action that returns a FileStreamResult.

return File(htmlStream, "application/msword", "myfile.doc");

The htmlStream content includes an image with base64 data as the source:

<img src='data:image/png;base64,my_base_64_data_goes_here' />

The image does not appear in the Word file.

Notes and findings:

  1. The HTML content appears fine in the browser
  2. It does not appear in the Word file (it appears as an 'X', as when the image isn't available).
  3. Clicking on the 'X' in the Word and select "Edit Alt Text" confirms that it has the correct data (data:image/png;base64,my_base_64_data_goes_here).
  4. I do not know the MIME type of the image represented by the base64 data. But it works in the browser as an image tag in an HTML page.

What can I do to get the Word document with the image?

Zesty
  • 2,922
  • 9
  • 38
  • 69
  • 1
    https://superuser.com/a/166288 – CBroe Aug 29 '17 at 09:19
  • Currently embedding image tag with Base64 unsupported by Word, use MHT format (see https://stackoverflow.com/questions/31250/content-type-for-mht-files for its MIME type) & then perform conversion to DOC(X) format. – Tetsuya Yamamoto Aug 29 '17 at 09:46

0 Answers0