How to Extract Pages From Word Documents in Python

How to Extract Pages From Word Documents in Python

You may need to split word document into multiple documents by page 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 Python developer, you can split word document into separate files online on the cloud. In this article, you will learn how to extract pages from word documents in Python.

The following topics shall be covered in this word page splitter article:

Word Documents Splitter REST API - Python SDK

To split word file into multiple files, I will be using the Python SDK of GroupDocs.Merger Cloud API. It allows you to rotate, split, join, remove and rearrange a single page or a collection of pages from supported document formats of Word, Excel, Visio drawings, PDF, and HTML. Python source code repository is freely available on the GitHub.

Word file splitter free download is available. You can install word doc splitter to your Python application with PIP from PyPI by using the following command in the terminal:

pip install groupdocs-merger-cloud

Please get your Client ID and Secret from the dashboard before following the below mentioned steps. Once you have your ID and Secret, add the below code into your application to split word document into separate files as shown below:

How to Split Word Document into Single Document in Python

You can split docx programmatically on the cloud by following the steps mentioned below.

  • Upload the word file to the cloud
  • Split word document on the cloud
  • Download the extracted document

Upload Word Document

Firstly, we will upload the word files to the cloud to extract pages from word online using the code example given below:

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

Split Word Document Pages in Python

You can split word pages into separate files programmatically by following the steps given below:

  • Firstly, create an instance of the DocumentApi.
  • Then, create an instance of the SplitOptions
  • Now, create an instance of the FileInfo
  • Pass input file path as argument to FileInfo
  • Next, provide output file path
  • Set specific page numbers in a comma separated array
  • Now, set docx split mode to Pages. It allows to split page numbers in a comma separated array
  • Create SplitRequest with SplitOptions
  • Finally, call the DocumentAPI.split() method with SplitRequest as argument and get results

The following code snippet shows how to split word file into separate pages using REST API in Python:

How to Split Word File into Separate Pages in Python

How to Split Word File into Separate Pages in Python

Download the Single File

Finally, the above code sample will save the separated file on the cloud using python. It can be downloaded using the following code sample:

Split Word Document into Single Ones by Page Range in Python

You can split word document into multiple documents by page online using the following steps given below:

  • Create an instance of the DocumentApi
  • Then, create an instance of the SplitOptions
  • Now, create an instance of the FileInfo
  • Pass input file path as argument to FileInfo
  • Next, provide output file path as “python-testing”
  • Set start_page_number and end_page_number values
  • Set docx split mode to Pages to split word
  • Create SplitRequest with SplitOptions
  • Finally, call the DocumentAPI.split() method with SplitRequest as argument

The following code snippet shows how to extract pages from a word document in Python using REST API:

Split Word Documents into Separate Files by Applying Filter

You can split word document into multiple documents by page online using range mode and filter programmatically as shown below:

  • Create an instance of the DocumentApi
  • Then, create an instance of the SplitOptions
  • Now, create an instance of the FileInfo
  • Pass input file path as argument to FileInfo
  • Next, provide output file path as “python-testing”
  • Set start_page_number and end_page_number values
  • Next, set range_mode to “OddPages
  • Set docx split mode to Pages to split word
  • Create SplitRequest with SplitOptions
  • Finally, call the DocumentAPI.split() method with SplitRequest as argument

The following code snippet shows how to extract word document pages by applying filter using REST API in Python:

How to Split Word Doc into Multiple Files using Python

You can split word file into multiple documents programmatically by following the steps given below:

  • Create an instance of the DocumentApi
  • Then, create an instance of the SplitOptions
  • Now, create an instance of the FileInfo
  • Pass input file path as argument to FileInfo
  • Next, provide output file path as “python-testing”
  • Then, set pages collection in array format
  • Set docx split mode to **_Intervals _**to split word
  • Create SplitRequest with SplitOptions
  • Finally, call the DocumentAPI.split() method with SplitRequest as argument

The following code snippet shows how to split docx into multiple files using REST API in Python:

Online Split Word File

How to split word document into multiple files online free? You can try our word document splitter online to split word document into multiple files online free by a fixed number of pages or in various page ranges. Multiple pages word documents are divided into multiple word files keeping the format of the original document.

Conclusion

In this tutorial, we have learned:

  • how to split word file into two in Python on the cloud;
  • how to split docx file into separate files in Python;
  • Programmatically how to split word document by page in Python;
  • programmatically how to split word document into multiple documents online in Python;
  • how to split word file online free using online word page splitter;

Additionally, you can learn more about GroupDocs.Merger Cloud API using the documentation. We also provide an API Reference section that lets you visualize and communicate with our APIs directly through the browser. Moreover, please see the GroupDocs.Merger Cloud SDK for Python Examples here.

Ask a question

If you have any questions about how to extract pages from word document online, please feel free to ask us on the Forum

FAQs

How to extract pages from word document online using docx splitter API?

Install document splitter free download Python library to extract word pages online. You can visit the documentation for complete API details.

What is the fastest way to split word document free online?

Word page extractor online works very fast and you can split docx online in a few seconds.

How to extract page from word online for free?

  • Open online word page extractor.
  • Click inside the file drop area to upload word docx file or drag & drop word file.
  • Click on Convert button. Your document will be uploaded and converted to DOC format.
  • Download link of output files will be available instantly after split.

Is it safe to use free online doc splitter?

Yes, document splitter word is safe and no one has access to your uploaded files. We delete uploaded files after 24 hours.

See Also