Word is the word most popular program for creating documents. But when working with bigger word documents, you may need to change the order of your pages. Rather than starting from scratch, you could consider rearranging the pages so that they end up in better order. So, it is very important to know how to change pages order in Word. In this article, you will learn how to move, reorder, and rearrange pages in word using Ruby.
The following topics shall be covered in this article:
- REST API to Rearrange Word Pages - Installation
- How to Rearrange Pages in Word Document using Ruby
- How to Swap Word DOCX Pages using REST API in Ruby
REST API to Rearrange Word Pages - Installation
To rearrange word pages online, we will be using the Ruby SDK of GroupDocs.Merger Cloud API. This API allows us to split, merge and delete unwanted pages from word documents. You can also reorder a single page or a collection of pages within supported document formats. Please install it using the following command in the rails console:
gem 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 in the code as shown below:
Next, follow the below steps to change order of pages in word on the cloud.
How to Rearrange Pages in Word Document using Ruby
Rearrange word pages by moving any page to a new position in word document programmatically on the cloud. We will reorganize word pages by following the steps given below:
- Firstly, create an instance of the PagesApi.
- Next, create an instance of the MoveOptions.
- Then, create an instance of the FileInfo.
- Set the input word file path and output file path
- Next, set the current page number and new page number.
- After that, create the MoveRequest with MoveOptions as an argument.
- Finally, call the move() method and save the updated word document.
The following code sample shows how to rearrange pages in word online using REST API in Ruby:
Finally, the above code sample will save the reorganized Docx pages on the cloud. How to rearrange pages in word for free? Please try the following free online word combiner and reorder tool, which is developed using the above API.
How to Swap Word DOCX Pages using REST API in Ruby
Exchange the position of two word pages within word document by following the steps given below:
- Firstly, create an instance of the PagesApi.
- Next, create an instance of the SwapOptions.
- Then, create an instance of the FileInfo.
- Set the input Docx file path and output file path
- Next, set the current page number and new page number.
- After that, create the SwapRequest with SwapOptions as an argument.
- Finally, call the swap() method and save the updated document.
The following code sample shows how to change the order of pages in word document using REST API in Ruby:
Finally, the above code sample will save the swapped word pages on the cloud. How to reorder pages in docx online? Please try the following free online tool to change order of word pages online, which is developed using the above API.
Summing up
In this article, we have learned:
- how to rearrange and reorganize pages in word;
- how to swap and reorder pages in word file;
You may learn more about GroupDocs.Conversion Cloud API from the documentation. We also have an API Reference section that lets you visualize and communicate with our APIs directly through the browser.
Ask a question
For queries about how to rearrange page order in word, feel free to ask us via the Support Forum
See Also
- Split PDF Documents using REST API in Node.js
- Rotate PDF Online and Flip PDF Online Free
- Split Word File into Multiple Files and Separate Pages in Word
- Combine PDFs into One, Merge Multiple PDF into One and PDF Combiner Online
- Merge Word Files and Merge DOC Files
- Merge Documents of Different Types using REST API in Python
- Extract Specific Pages from PDF using Python