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

Free Support Forum - aspose.com

Position of the image is different in the result of saving in HTML format

Hi Aspose team


We are working on saving Word files in HTML format for cross-platform viewing with Aspose Word 15.0.3.

Here is our code for conversion test:
Document doc = new Document(“custom/input/docx/HAWAY_Improvement.2.doc”);
Document pageDoc;
LayoutCollector layoutCollector;
DocumentPageSplitter splitter;
ByteArrayOutputStream output = new ByteArrayOutputStream();
HtmlSaveOptions saveOp = new HtmlSaveOptions();
saveOp.setExportImagesAsBase64(true);
saveOp.setExportTextInputFormFieldAsText(false);
saveOp.setExportTocPageNumbers(true);
saveOp.setExportPageSetup(true);
saveOp.setExportDocumentProperties(true);
saveOp.setExportRelativeFontSize(false);

layoutCollector = new LayoutCollector(doc);
doc.updatePageLayout();
splitter = new DocumentPageSplitter(layoutCollector);

byte[] outputContent;
String outputPath = “custom/output/docx”;
String blockID = UUID.randomUUID().toString();

for (int page = 1; page <= doc.getPageCount(); page++) {
pageDoc = splitter.getDocumentOfPage(page);
output.reset();
pageDoc.save(output, saveOp);

outputContent = output.toByteArray();

File outputDir = new File(outputPath + “/” + blockID + “/”);
if (!outputDir.exists())
outputDir.mkdir();

IOUtils.write(outputContent, new FileOutputStream(outputPath + “/” + blockID + “/” + page + “.html”));

}

In this Word file, there is a image in page header on the left of entire page.
However this image is not shown correctly in the result.

I have uploaded a comparison image , the Word file, and the result.

Please help us figure it out what’s going on in this scenario, thank you


Craig

Hi Craig,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. If you convert the contents of document's header into html using MS Word, you will get the same output.

We have tested the scenario using latest version of Aspose.Words for Java 16.11.0 and have not found any issue with output document. Please use Aspose.Words for Java 16.11.0.

Hi Tahir.ManZoor


Thanks for your information!

I am sorry about that, we thought is was align right, but we did not notice that the image in the pageheader is in a fixed-position.

Therefor, if we adjust the width of the result, this image is still in the same position.

A thanks for your help again :slight_smile:

Craig