How to extract pages from word document online using Node.js

How to Extract Pages from Word DOC/DOCX Online using Node.js

You may need to extract word document pages into multiple documents programmatically. By splitting word documents, you can easily extract page from word document and share a specific information or data with the stakeholders. As a Node.js developer, you can extract word document into separate files online on the cloud. In this article, you will learn how to extract pages from word DOC/DOCX online using Node.js.

The following topics shall be covered in this article:

Word Page Extractor Online REST API and Node.js SDK

In order to extract pages from Word document, I will be using the Node.js SDK of GroupDocs.Merger Cloud API. It is online Word page extractor free download library. It allows you to split, combine, extract, remove and rearrange a single page or a collection of pages from supported document formats of Word, Excel, PowerPoint, Visio drawings, PDF, and HTML.

You can install GroupDocs.Merger cloud to extract Word pages from your Node.js application using the following command in the console:

npm install groupdocs-merger-cloud

Please get your Client ID and Secret from the dashboard before following the mentioned steps. Once you have your ID and secret, add in the code as shown below:

Extract Pages from Word into New Document by Exact Page Numbers

You can export specific pages from Word file programmatically on the cloud by following the simple steps mentioned below:

  • Upload the Word file to the Cloud
  • Extract Word pages using REST API in Node.js
  • Download the separated files

Upload the Word File

Firstly, upload the Word file to the cloud using the code example given below:

As a result, the uploaded Word file will be available in the files section of your dashboard on the cloud.

Extract Word Pages using REST API in Node.js

You can easily extract pages of Word file programmatically by following the steps given below:

  • Firstly, create an instance of the PagesApi.
  • Create an instance of the ExtractOptions.
  • Create an instance of the FileInfo.
  • Then, set path to the input Word file.
  • Next, set path to the extracted Word file.
  • Set specific page numbers in a comma separated array to extract Word file.
  • Create ExtractRequest with ExtractOptions.
  • Finally, call the pagesApi.extract() method with ExtractRequest to get results.

The following code snippet shows how to extract Word pages into separate files using REST API in Node.js:

Download the Extracted Files

The above code sample will save the separated files on the cloud. You can download them using the following code sample:

Extract Word Document Pages by Page Range using REST API in Node.js

You can extract and save pages from a Word separately by providing a range of page numbers programmatically by following the steps given below:

  • Firstly, create an instance of the PagesApi.
  • Create an instance of the ExtractOptions.
  • Create an instance of the FileInfo.
  • Then, set path to the input Word file.
  • Next, set path to the extracted Word file.
  • Set the startPageNumber and the endPageNumber values.
  • Then, set the rangeMode as EvenPages or OddPages
  • Create ExtractRequest with ExtractOptions.
  • Finally, call the pagesApi.extract() method with ExtractRequest to get results.

The following code snippet shows how to extract pages from Word online using page range and page mode in Node.js:

Similar way, you can extract odd pages from Word documents.

Try Online

How to extract pages from Word document online? Please try the following free online Word extractor tool to extract pages from Word online free. This Word page extractor free online tool is developed using the above API.

Conclusion

In this article, you have learned:

  • how to extract certain pages from Word document online using REST API;
  • how to extract pages from Word document using page range and range mode filter;
  • upload Word file to the cloud to export selected pages from Word online;
  • download and save certain pages of Word from the cloud;
  • how to extract pages from Word free;

Now, you know how to extract all pages from Word document or how to save certain pages of a Word. The API also enables you to reorder or replace document pages, change page orientation, manage document passwords and perform other manipulations easily for any supported file format. Besides, you can learn more about GroupDocs.Merge Cloud API using the documentation. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser.

Ask a question

You can ask your queries about word page extractor to export selected pages from Word, via our Free Support Forum

FAQs

How to extract multiple pages from Word into one file ?

Install JS library for separating Word files into multiple pages online programmatically. You can visit the documentation for complete API details.

How long does it take to extract specific pages from Word ?

JavaScript HTML to Word library works very fast and you can extract pages from protected Word easily in a few seconds.

See Also