Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to Separate and Split PDF Files using REST API in Ruby
# How to Split PDF Files into multiple page PDFs
# 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-files/split-pdfs.pdf"
@options.output_path = "split-files"
@options.pages = [3, 6, 8]
@options.mode = "Intervals"
@result = @documentApi.split(GroupDocsMergerCloud::SplitRequest.new(@options))
puts("Split PDF File into Multiple Pages File.")
# How to Split PDF file into Single Page Document with Exact Page Number
# 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-files/split-pdfs.pdf"
@options.output_path = "split-files"
@options.start_page_number = 3
@options.end_page_number = 7
@options.mode = "Pages"
@result = documentApi.split(GroupDocsMergerCloud::SplitRequest.new(@options))
puts("Extrated by Page Number using REST API.")
# How to Split PDF file into one page File by applying filter
# 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-files/split-pdfs.pdf"
@options.output_path = "split-files"
@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("Separated Pages by Page Range Mode.")
# How to Split and Separate PDF Files into One Page Document
# 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-files/split-pdfs.pdf"
@options.output_path = "split-files"
@options.pages = [1, 3]
@options.mode = "Pages"
@result = @documentApi.split(GroupDocsMergerCloud::SplitRequest.new(@options))
puts("Split PDF Files into One Page Documents.")
# 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"

You can split PDF files programmatically on the cloud using Ruby Cloud REST API. In this article, you will learn how to split PDF files using REST API in Ruby.

The following topics are covered in this article:

  1. PDF File Splitter REST API and Ruby SDK
  2. Split PDF Files into One-Page Documents using Ruby
  3. How to Split PDF Files into Multi-Page PDF using Ruby
  4. Split PDF to Single Page Files by Providing Exact Page Number
  5. Split PDF to One-Page Files by Applying Filter using Ruby
  6. Free Online Split PDF Files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment