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

Free Support Forum - aspose.com

Aspose.Words saving as HTML text below image

We have a template which we render and create an Aspose document object from, if this is saved to a word document (see attached VanWord.docx) the text for the number plate is on the image as we expect. If we save this Aspose document as HTML the text is below the image (see attached VanHTMLScreenshot.docx).

The code snippet below shows you how we save the HTML, we believe we have to use windows-1252 rather than utf-8 to save the html, hence replacing the encoding version.

// We want to save images to separate files
string imagePath = htmlName.Replace(Path.GetExtension(htmlName), "") + "_Files";
if (!Directory.Exists(imagePath))
    // Create the images folder
options.ImagesFolder = imagePath;

string html;

using (MemoryStream stream = new MemoryStream())
    document.Save(stream, options);
    stream.Position = 0;

    // Read the bytes back in utf8 format.
    using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
        html = reader.ReadToEnd();

// Replace the encoding version.
html = html.Replace("charset=utf-8", "charset=windows-1252");

// Write the bytes to the file.
using (StreamWriter writer = new StreamWriter(new FileStream(htmlName, FileMode.Create), Encoding.GetEncoding(1252)))

// Set the html filename on the return object.
documentResult.RenderedHTMLDocument = System.Text.Encoding.UTF8.GetBytes(htmlName);

Hi Sarah,

Thanks for your inquiry. Please note that
Aspose.Words mimics the same behavior as MS Word does. Aspose.Words
converts the MS Word documents to html (MS Word save option “Web Page, Filtered”). If you convert your document to HTML by using MS Word, you will get the same output.

Moreover, upon processing HTML, some
features of HTML might be lost. You can find a list of limitations upon
HTML exporting/importing here:

Please let us know if you have any more queries.