I was testing an idea I’ve read in the forums. I want to change absolute paths to relative path to images linked in html file. But in the process of reading and writing a new character, À, is added at the beginning, and the last > from ‘’ is truncated.
I send the result in a byte array, and the ‘client application’ regenerates the file with this byte array:
Code:
Aspose.Words.Document docWord = new Aspose.Words.Document(strFilePath);
System.IO.MemoryStream
htmlStream = new System.IO.MemoryStream();
docWord.SaveOptions.HtmlExportHeadersFooters = true;
docWord.SaveOptions.ExportPrettyFormat
= true;
docWord.Save(htmlStream,
SaveFormat.Html);
BinaryReader brHTML = new BinaryReader(htmlStream, System.Text.Encoding.UTF8);
htmlStream.Seek(0, SeekOrigin.Begin);
string strTextoHTML = new string(brHTML.ReadChars((int)htmlStream.Length));
brHTML.Close();
htmlStream.Close();
/*
StreamReader srHTML = new StreamReader(htmlStream);
htmlStream.Seek(0,SeekOrigin.Begin);
string strTextoHTML = srHTML.ReadToEnd();
srHTML.Close();
htmlStream.Close();
*/
htmlStream = new System.IO.MemoryStream();
BinaryWriter bwHTML = new BinaryWriter(htmlStream, System.Text.Encoding.UTF8);
bwHTML.Write(strTextoHTML);
byte[] bytesFile = htmlStream.ToArray();
bwHTML.Close();
htmlStream.Close();
// Client Application
FileStream streamFile = new FileStream(System.IO.Path.GetTempFileName(), FileMode.OpenOrCreate, FileAccess.Write);
streamFile.Write(bytesFile, 0, byteArray.GetUpperBound(0));
streamFile.Close();
I attached the original document and the files obtained after the conversion.
Thanks for the attention.