How to Extract documents pages of Word document

i am still facing this issue, unable to find the class DocumentPageSplitter in java, am using com.aspose:aspose-words:20.2:jdk17’ and com.aspose:aspose-words:20.2:javadoc

@1623751199347

We suggest you please use the Document.extractPages method as shown below instead of PageSplitter utility. This method returns the Document object representing specified range of pages.

Document doc = new Document(MyDir + "input.docx");
Document dst = doc.extractPages(0, 1);;
dst.save(MyDir + "output.pdf");

Thank you Tahir for the response… i even tried this …but it says Cannot resolve method ‘extractPages’ in ‘Document’ , we are using aspose-words:20.2:jdk16 and aspose-words:20.2:javadoc

@1623751199347

Please use the latest version of Aspose.Words for Java 21.9 to avoid the shared issue.

hey…it worked…thank you…

Tahir, Is there any other we can extract first few pages /words to another document without upgrading to latest version ?

@1623751199347

In this case, we suggest you two solutions.

  1. Use the the PageSplitter utility to extract the desired pages. Please get its code from following GitHub link.
    https://github.com/aspose-words/Aspose.Words-for-Java

  2. Extract the content between nodes. You can find the page number of start and end node of your document using LayoutCollector.GetStartPageIndex method and use the code example shared in the following article.
    https://docs.aspose.com/words/java/extract-selected-content-between-nodes/