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/default/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.
In case the problem still remains, please ZIP and attach the following resources here for testing:
Your simplified input Word document
Aspose.Words generated intermediate HTML output file
Aspose.Words generated final Word document showing the undesired behavior.
As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.
Both DOCX files in your Temp.zip were generated by using Aspose.Words for .NET 18.6.
But we need the following information to reproduce the issue with Aspose.Words on our end:
Your simplified input Word document
Aspose.Words generated intermediate HTML output file (please save the HTML string into a HTML file)
Aspose.Words generated final Word document showing the undesired behavior.
Please also create a comparison screenshot highlighting (encircle) the problematic areas in final Aspose.Words generated DOCX file and attach it here for our reference.
We have spotted a few problems and logged an issue in our issue tracking system. The ID of this issue is WORDSNET-17031.
Please also create a comparison screenshot highlighting (encircle) the problematic areas between source document (Template.docx) and this final Aspose.Words generated DOCX file (18.6-final.docx) and attach it here for our reference. Thanks for your cooperation.