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:
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();
}
}