Hi there,
I need to develop a Word-html-Word editor, I use CK-Editor and Aspose.Word to do this. I found the format of result document is different from the original. The unacceptable part is some paragraph is higher than the source, although my user accepted these two shouldn’t be the same.
The export to html file code as following:
if (!IsPostBack)
{
string fileName = Request[“srcFile”];
hidFileName.Value = fileName;
Document doc = new Document(“D:\Temp\”+ fileName);
Aspose.Words.Saving.HtmlSaveOptions hso = new Aspose.Words.Saving.HtmlSaveOptions();
hso.ExportImagesAsBase64 = true;
hso.ExportHeadersFootersMode = Aspose.Words.Saving.ExportHeadersFootersMode.None;
hso.SaveFormat = Aspose.Words.SaveFormat.Html;
hso.PrettyFormat = true;
hso.MetafileFormat = Aspose.Words.Saving.HtmlMetafileFormat.EmfOrWmf;
hso.ExportListLabels = Aspose.Words.Saving.ExportListLabels.AsInlineText;
hso.ExportRoundtripInformation = true;
MemoryStream ms = new MemoryStream();
doc.Save(ms, hso);
ms.Position = 0;
StreamReader sr = new StreamReader(ms);
string strContent = sr.ReadToEnd();
int removeStart = strContent.IndexOf("", StringComparison.OrdinalIgnoreCase);
int removeEnd = strContent.IndexOf("", removeStart + 1, StringComparison.OrdinalIgnoreCase);
myEditor.InnerHtml = strContent.Substring(0, removeStart - 1) + strContent.Substring(removeEnd + 8);
}
The output file code is
Aspose.Words.Document doc = new Aspose.Words.Document();
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
// Apply the paragraph style to the current paragraph in the document and add some text.
builder.StartBookmark("MyBookmark");
builder.InsertHtml(myEditor.InnerText);
builder.EndBookmark("MyBookmark");
string fileName = hidFileName.Value.Replace("Temp", "");
doc.Save("D:\\Temp\\"+fileName, SaveFormat.Docx);
Do you have any idea about how to fix it? <a class="attachment" href="/uploads/discourse_instance3/15789">Temp.zip</a> (36.9 KB)
The TempXXX.docx is the source file, the result file created by Aspose.Word is “991107XXX.doc” in the attachment.