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
Directory.CreateDirectory(imagePath);
}
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)))
{
writer.Write(html);
}
// Set the html filename on the return object.
documentResult.RenderedHTMLDocument = System.Text.Encoding.UTF8.GetBytes(htmlName);