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

Free Support Forum - aspose.com

HTML to Word conversion - Issue with image position in exported doc

Hi,

We have purchased the Aspose.Word dll for .NET (Developer OEM). We need some help/guidance on an issue that we are seeing.

In our application we are doing the following:

1) Importing a word document into the application.
2) Exporting the document using a word template which we create manually.

In one of our import word documents there is an image which is placed in the upper right corner of a table within a section. While importing we are saving this content as HTML. We are exporting the word document from the saved html content using the word template. When we export the document, we find that the position of the image is not in its correct place, when compared with the imported word doc.

We are using the following block of code to import the word content into our database as HTML:

string url = @"C:\Sample Word Docs\";

Aspose.Words.Document srcDoc = new Document(url + "Import.docx");
Aspose.Words.Document dstDoc = new Aspose.Words.Document();
dstDoc.Sections.Clear();
Aspose.Words.NodeImporter importer = new Aspose.Words.NodeImporter(srcDoc, dstDoc, Aspose.Words.ImportFormatMode.KeepSourceFormatting);
Aspose.Words.Section newSection = (Aspose.Words.Section)importer.ImportNode(srcDoc.Sections[2], true);
dstDoc.Sections.Add(newSection);

Aspose.Words.Saving.HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions();
saveOptions.ImagesFolder = url + "Images";
saveOptions.CssStyleSheetType = Aspose.Words.Saving.CssStyleSheetType.Embedded;
saveOptions.SaveFormat = SaveFormat.Html;
MemoryStream htmlStream = new MemoryStream();
dstDoc.Save(htmlStream, saveOptions);
string htmlText = Encoding.UTF8.GetString(htmlStream.GetBuffer());
htmlStream.Close();


And below is the code to export the word document using the word template:
Aspose.Words.Document expDoc = new Document(url + "Template.docx");
DocumentBuilder db = new DocumentBuilder(expDoc);
db.MoveTo(expDoc.Sections[2].Body.FirstChild);
db.InsertHtml(htmlText);
expDoc.Save(url + "Exported.docx");

Attached zip file contains 3 documents:
1) 'Import.docx' which we import in our application.
2) 'Exported.docx' which we export from our application using the 'Template.docx'

If you view the 'Import.docx' file you will notice that the image is in the upper right corner on the page however in the 'Exported.docx', the same image is in the center.

Basically we want the position of the image in the Exported docx to match with the Imported docx.

Could you please help?

Thank you.


Hi Vipul,

Thanks for your inquiry. I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-11104. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-11104) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.