PDF Splitter - How to Extract Pages from PDF using Rest API in Ruby

How to Extract Pages from PDF using Rest API in Ruby

You may need to extract specific pages from PDF documents or may need to split pdf to individual pages as smaller parts. As a Ruby developer, you can easily extract pages from pdf adobe reader by page numbers or by a range of pages programmatically. In this article, you will learn how to extract pages from PDF using REST API in Ruby and how to extract pages from pdf online free.

The following topics shall be covered to convert pdf to separate pages in this tutorial:

PDF Splitter REST API and Ruby SDK

To split pdf to pages, we will use pdf extractor free download Cloud API Ruby SDK of GroupDocs.Merger. It is a feature-rich and high-performance Cloud SDK used to save one page from pdf or for how to save certain pages of a pdf into a single document. It also enables adobe acrobat extract pages from pdf into multiple files. The SDK offers functionality to swap, move, remove, rotate or change the page orientation for a whole or preferred range of pages. You can perform other manipulations easily for any supported file formats such as PDF, Word, Powerpoint, and Excel worksheets. It supports .NET, Java, PHP, Python, Android, and Node.js SDKs as its document merger family members.

You can install GroupDocs.Merger-Cloud to select pages from pdf in Ruby project using the following command in the console:

gem install groupdocs_merger_cloud

Please get your Client ID and Client Secret from the dashboard before you start following the steps and available code examples. Once you have your ID and secret, add in the code as demonstrated below to split pdf file into pages:

Extract Specific Pages from PDF using REST API

You can save specific pages of pdf by page numbers from the uploaded PDF file. First of all, upload the multipage PDF document to the cloud and the PDF file will be available in the files section of your dashboard. Please follow the steps mentioned below to save certain pages of pdf from a PDF document programmatically.

  • Firstly, Create an instance PagesApi
  • Then, create ExtractOptions instance
  • Next, create an instance of FileInfo
  • Set the input file path and output directory path
  • Provide comma separated page numbers to extract
  • Next, create an instance of ExtractRequest
  • Finally, extract PDF pages by calling the PagesApi.extract() method with ExtractRequest

The following code example shows how to extract files by providing specific page numbers from a PDF document using a REST API.

The above code sample will save the extracted pages in separate PDF files on the cloud.

Extract Pages from PDF by Even Page Range

Please follow the steps mentioned below for how to extract documents from pdf by providing a page range programmatically.

  • Firstly, Create an instance PagesApi
  • Then, create ExtractOptions instance
  • Next, create an instance of FileInfo
  • Set the input file path and output directory path
  • Provide start_page_number and end_page_number options
  • Set range_mode to EvenPages
  • Next, create an instance of ExtractRequest
  • Finally, extract PDF pages by calling the PagesApi.extract() method with ExtractRequest

The following code example shows to split pages in pdf by providing a page range from a PDF document using a REST API. Please follow the steps mentioned earlier to upload the files.

Extract Pages from PDF by Odd Page Range

Please follow the steps mentioned below to extract pages from pdf document by providing a page range programmatically.

  • Firstly, Create an instance PagesApi
  • Then, create ExtractOptions instance
  • Next, create an instance of FileInfo
  • Set the input file path and output directory path
  • Provide start_page_number and end_page_number options
  • Set range_mode to OddPages
  • Next, create an instance of ExtractRequest
  • Finally, extract PDF pages by calling the PagesApi.extract() method with ExtractRequest

The following code example extract pdf pages from pdf file by providing a page range from a PDF document using a REST API. Please follow the steps mentioned earlier to upload the files.

Now, you can split a PDF file by page ranges or extract all PDF pages to multiple PDF files using Rest API.

Online Extract PDF Pages using PDF Splitter

How to extract pages from pdf free? Split or extract PDF pages online with easy-to-use free online extract pdf pages tool. You can extract pages from pdf free using our PDF splitter. Separating pdf pages is absolutely safe. Try it today.

Summing up

In this article, we have learned how to extract pages from a PDF document on the cloud using Ruby. You also learned how to programmatically split pdf to pages by pages range or number on the cloud. Now you know how to export a single page from a pdf and how to extract multiple pages from pdf files quickly. You can learn more about GroupDocs.Merger 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

If you have any queries about how to extract single page from pdf or how to split pdf into multiple pages, please feel free to ask us on the Forum

See Also