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

Free Support Forum - aspose.com

How to get a specified page in the given word document

Hi,
As per our business requirement, we need to perform the below operations.

  1. We need to get a specified page in the given word document.
  2. Once we get the page, we need to modify the mail merge fields data. (we have an approach how to update the mail fields data)
  3. We need to update the document with the latest data.

Thank You,
Ramasubrahmanyam T

Hi Ramasubrahmanyam,


Thanks for your inquiry. You can get/extract specific page using Aspose.Words and perform mail merge using modified data.

If you want to extract specific page from Word document, you can achieve this using the “PageSplitter” example project. You can find PageSplitter code in Aspose.Words for Java examples repository at GitHub. Please check following code example for your kind reference.

If this does not help you, please share some more detail about your query along with input and expected output documents. We will then provide you more information about your query along with code.

//Load the document<o:p></o:p>

Document doc = new Document(MyDir + "in.docx");

// Create and attach collector to the document before page layout is built.

LayoutCollector layoutCollector = new LayoutCollector(doc);

// Split nodes in the document into separate pages.

DocumentPageSplitter splitter = new DocumentPageSplitter(layoutCollector);

//Get the first page of document

Document newDoc = splitter.GetDocumentOfPage(1);

newDoc.save(MyDir + "Out.docx");