Hi there
I use Aspose Word 17.4 to split Word files page by page, and save them into HTML format.
It seem that the numbering is not continuing in the page below page #1, after splitting.
Please check the attachment, there is the Word file along with the page result.
And also my testing code:
public void testForAspose() {
try {
Document document = new Document(“input/meowBase.docx.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();
}
}