Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save groupdocs-cloud-gists/f6c7c653c7a68402cb2e6883e9e95569 to your computer and use it in GitHub Desktop.
Save groupdocs-cloud-gists/f6c7c653c7a68402cb2e6883e9e95569 to your computer and use it in GitHub Desktop.
How to Change Page Orientation in Word Document using Ruby
# Create an instance of the Pages API
@pagesApi = GroupDocsMergerCloud::PagesApi.from_keys(@app_sid, @app_key)
@options = GroupDocsMergerCloud::OrientationOptions.new
@options.file_info = GroupDocsMergerCloud::FileInfo.new
@options.file_info.file_path = 'change-page-orientation/four-pages.docx'
@options.output_path = "change-page-orientation/to-landscape.docx"
@options.pages = [2, 4]
@options.mode = "Landscape"
@result = @pagesApi.orientation(GroupDocsMergerCloud::OrientationRequest.new(@options))
puts("Successfully changed word document orientation from Portrait to Landscape.")
# Create an instance of the Pages API
@pagesApi = GroupDocsMergerCloud::PagesApi.from_keys(@app_sid, @app_key)
@options = GroupDocsMergerCloud::OrientationOptions.new
@options.file_info = GroupDocsMergerCloud::FileInfo.new
@options.file_info.file_path = 'change-page-orientation/four-pages.docx'
@options.output_path = "change-page-orientation/to-portrait.docx"
@options.pages = [2, 4]
@options.mode = "Portrait"
@result = @pagesApi.orientation(GroupDocsMergerCloud::OrientationRequest.new(@options))
puts("Successfully changed word document orientation from Landscape to Portrait.")
# 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"

Learn how to change Word documents orientation in Ruby using Cloud REST API:

The following topics shall be covered in this article:

  1. API for Changing Word Page Orientation to Landscape or Portrait
  2. Change Orientation of Word Pages to Landscape in Ruby
  3. Change Orientation of Word Document to Portrait in Ruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment