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

Free Support Forum - aspose.com

Save a Word file into HTML format- and image shifted in the result

Hi there


I am recently using Aspose Word 17.4 for converting Word files to HTML files.
I’ve got a problem that there is some text block down-shifted in the result.

Please see the attachment. I got the Word file and the result in there.

And also the testing code here:

@Test
public void testForAspose() {
try {
Document document = new Document(“input/Mockup_Test.docx”);
Document pageDocument;
LayoutCollector layoutCollector;
DocumentPageSplitter pageSplitter;
ByteArrayOutputStream output = new ByteArrayOutputStream();
HtmlSaveOptions htmlSaveOp = new HtmlSaveOptions();
htmlSaveOp.setExportImagesAsBase64(true);
htmlSaveOp.setExportTextInputFormFieldAsText(false);
htmlSaveOp.setExportTocPageNumbers(true);
htmlSaveOp.setExportPageSetup(true);
htmlSaveOp.setExportDocumentProperties(true);
htmlSaveOp.setExportRelativeFontSize(false);
htmlSaveOp.setUpdateFields(true);
layoutCollector = new LayoutCollector(document);
document.updatePageLayout();
pageSplitter = new DocumentPageSplitter(layoutCollector);

byte[] htmlByteArray;
String outPath = “output/”;
String targetDir = UUID.randomUUID().toString();

File outputDir = new File(outPath + “/” + targetDir + “/”);
if (!outputDir.exists())
outputDir.mkdir();
ByteArrayOutputStream savingOutputStream = new ByteArrayOutputStream();

for (int pageNum = 1; pageNum <= document.getPageCount(); pageNum++) {
System.out.println(“page:” + pageNum);
pageDocument = pageSplitter.getDocumentOfPage(pageNum);

savingOutputStream.reset();
output.reset();

pageDocument.save(output, htmlSaveOp);
htmlByteArray = output.toByteArray();

IOUtils.write(htmlByteArray, new FileOutputStream(outPath + “/” + targetDir + “/” + pageNum + “.html”));
}

} catch (Exception e) {
e.printStackTrace();
}
}


Hi Cheng,


Thanks for your inquiry. We have tested the scenario and noticed that image is moving down in the resultant HTML. We have logged a ticket WORDSJAVA-1563 in our issue tracking system for further investigation and rectification. We will notify you as soon as it is resolved.

We are sorry for the inconvenience.

Best Regards,