How to read word each page?

992 Views Asked by At

I know doc.Save() function save all page in one HTML file. doc.RenderToScale() function save each page to the independent image file. but i want read or save each page in independent HTML file,I had not idea,can you help me?

1

There are 1 best solutions below

0
On

You can use the following code sample to convert each page to HTML or any other format supported by Aspose.Words.

String srcDoc = Common.DATA_DIR + "src.docx";
String dstDoc = Common.DATA_DIR + "dst {PAGE_NO}.html";

Document doc = new Document(srcDoc);
LayoutCollector layoutCollector = new LayoutCollector(doc);
// This will build layout model and collect necessary information.
doc.updatePageLayout();

// Split nodes in the document into separate pages.
DocumentPageSplitter splitter = new DocumentPageSplitter(layoutCollector);

// Save each page to disk as separate documents.
for (int page = 1; page <= doc.getPageCount(); page++)
{
    Document pageDoc = splitter.getDocumentOfPage(page);
    pageDoc.save(dstDoc.replace("{PAGE_NO}", page+""));
}

It depends on 3 other classes, which you can find in this zip file.

I work with Aspose as Developer Evangelist.