Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to Split Word Documents in Ruby
# For complete examples and data files, please go to https://github.com/groupdocs-merger-cloud/
# Create an instance of the Document API
@documentApi = GroupDocsMergerCloud::DocumentApi.from_keys(@app_sid, @app_key)
@options = GroupDocsMergerCloud::SplitOptions.new
@options.file_info = GroupDocsMergerCloud::FileInfo.new
@options.file_info.file_path = "split-document/split-pages10.docx"
@options.output_path = "split-document"
@options.pages = [3, 6, 8]
@options.mode = "Intervals"
@result = @documentApi.split(GroupDocsMergerCloud::SplitRequest.new(@options))
puts("Split Word DOCX into Multiple Pages Word Document using Ruby.")
# Create an instance of the Document API
@documentApi = GroupDocsMergerCloud::DocumentApi.from_keys(@app_sid, @app_key)
@options = GroupDocsMergerCloud::SplitOptions.new
@options.file_info = GroupDocsMergerCloud::FileInfo.new
@options.file_info.file_path = "split-document/split-pages10.docx"
@options.output_path = "split-document"
@options.pages = [1, 3]
@options.mode = "Pages"
@result = @documentApi.split(GroupDocsMergerCloud::SplitRequest.new(@options))
puts("Split Word Documents into One Page Documents using REST API in Ruby.")
# Create an instance of the Document API
@documentApi = GroupDocsMergerCloud::DocumentApi.from_keys(@app_sid, @app_key)
@options = GroupDocsMergerCloud::SplitOptions.new
@options.file_info = GroupDocsMergerCloud::FileInfo.new
@options.file_info.file_path = "split-document/split-pages10.docx"
@options.output_path = "split-document"
@options.start_page_number = 3
@options.end_page_number = 7
@options.mode = "Pages"
@result = documentApi.split(GroupDocsMergerCloud::SplitRequest.new(@options))
puts("Split Page Number using REST API in Ruby.")
# Create an instance of the Document API
@documentApi = GroupDocsMergerCloud::DocumentApi.from_keys(@app_sid, @app_key)
@options = GroupDocsMergerCloud::SplitOptions.new
@options.file_info = GroupDocsMergerCloud::FileInfo.new
@options.file_info.file_path = "split-document/split-pages10.docx"
@options.output_path = "split-document"
@options.start_page_number = 3
@options.end_page_number = 7
@options.range_mode = "OddPages"
@options.mode = "Intervals"
@result = @documentApi.split(GroupDocsMergerCloud::SplitRequest.new(@options))
puts("Extrated Pages by Page Range using REST API in Ruby")

You can split DOCX documents programmatically on the cloud using Ruby Cloud REST API. In this article, you will learn how to split word docx using REST API in Ruby.

The following topics are covered in this article:

  1. Word Splitter REST API and Ruby SDK
  2. Split Word Documents into One Page Documents using REST API in Ruby
  3. Split Word DOCX into Multiple Pages Word Document using Ruby
  4. Split Pages by Page Number using REST API in Ruby
  5. Split Pages by Page Range using REST API in Ruby
  6. Free Online Split Word Document
# Load the gem https://github.com/groupdocs-merger-cloud/groupdocs-merger-cloud-ruby in Ruby application for http://api.groupdocs.cloud
require 'groupdocs_merger_cloud'
# Get your client_id and client_secret from https://dashboard.groupdocs.cloud after free registration.
@app_sid = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
@app_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment