Hi there
I am recently using Aspose Word to change files into html format page by page (with 17.6)
I found a problem that the count of result page is different form the Word file
P.S. my test code:
@Test
public void testForAspose() {
String fileName = "140702-EIP KM Mockup_mod.docx";
try {
Document doc = new Document(fileName);
Document pageDoc;
LayoutCollector layoutCollector;
DocumentPageSplitter splitter;
HtmlSaveOptions saveOp = new HtmlSaveOptions();
saveOp.setExportImagesAsBase64(true);
saveOp.setExportTextInputFormFieldAsText(false);
saveOp.setExportTocPageNumbers(true);
saveOp.setExportPageSetup(true);
saveOp.setExportDocumentProperties(true);
saveOp.setExportRelativeFontSize(false);
saveOp.setUpdateFields(true);
layoutCollector = new LayoutCollector(doc);
doc.updatePageLayout();
splitter = new DocumentPageSplitter(layoutCollector);
byte[] outputContent;
String dirName = fileName;
new File(dirName + "/").mkdirs();
for (int page = 1; page <= doc.getPageCount(); page++) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
System.out.println("page:" + page);
pageDoc = splitter.getDocumentOfPage(page);
pageDoc.save(output, saveOp);
String result = new String(output.toByteArray(), "UTF-8");
outputContent = result.getBytes("UTF-8");
IOUtils.write(outputContent, new FileOutputStream(dirName + "/" + page + ".html"));
}
} catch (Exception e) {
e.printStackTrace();
}
}
There will be 16 result pages, but there are only 15 pages in word file.
B03.doc.zip (2.2 MB)