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

# Extracting Pages by number in ASPOSE.WORDS JAVA

I want to extract one/multiple pages from a document and save it to a pdf, docx or some other format. Is it possible?

What I want is some API like “public Document extractPages(fromIndex, toIndex)”

document is flow document and does not contain any information about
its layout into lines and pages. Therefore, technically there is no “Page” concept in Word document.
Pages are created by Microsoft Word on the fly.

Aspose.Words uses our own Rendering Engine to layout documents into pages. The
Aspose.Words.Layout namespace provides classes that allow to access
information such as on what page and where on a page particular document
elements are positioned, when the document is formatted into pages.

Please use the attached utility to extract the pages according to your requirements. Hope this helps you.

Document doc = new Document(“C:\Temp\in.doc”);
LayoutCollector layoutCollector = new LayoutCollector(doc);
doc.updatePageLayout();
DocumentPageSplitter splitter = new DocumentPageSplitter(layoutCollector);
Document pageDoc = splitter.GetDocumentOfPage(5);
pageDoc.save(“C:\Temp\out.doc”);pageDoc.save(“C:\Temp\out.pdf”);

I am not able to find DocumentPageSplitter class in aspose-words-14.5.0-jdk16 jar. Can you please let me know where should I get it

It is not working as expected you can check with this doc.

Thanks for your inquiry. We are checking this scenario and will get back to you soon.