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

Free Support Forum - aspose.com

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)”

Hi Abhradeep,

Thanks for your inquiry. Please note that MS Word
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);
DocumentPageSplitter splitter = new DocumentPageSplitter(layoutCollector);
Document pageDoc = splitter.GetDocumentOfPage(5);

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

Hi Abhradeep,

Thanks for your inquiry. Please download the Pagesplitter.zip from my previous post. This zip file contains the DocumentPageSplitter class.

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

Hi Abhradeep,

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

Hi Abhradeep,

Thanks for your inquiry. Please try attached classes. I hope, this helps.

Best regards,

I tested with that document and it is working as expected. I will test with other documents as well and let you know if I face any other issues.

Thanks for your quick reply.