Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert Word DOCX to Jpeg, Jpg, Png and Gif using Rest API.
# How to convert word docx to gif
# Getting instance of the Convert API
@apiInstance = GroupDocsConversionCloud::ConvertApi.from_keys(@app_sid, @app_key)
# Initialize convert settings
@settings = GroupDocsConversionCloud::ConvertSettings.new()
@settings.storage_name = @storage_name
@settings.file_path = "word-to-images/one-page.docx"
@settings.format = "gif"
# Set Word Docx LoadOptions
@loadOptions = GroupDocsConversionCloud::DocxLoadOptions.new()
@loadOptions.password = "password"
@settings.load_options = @loadOptions
@convertOptions = GroupDocsConversionCloud::GifConvertOptions.new()
@convertOptions.grayscale = true
@convertOptions.from_page = 1
@convertOptions.pages_count = 1
@convertOptions.quality = 100
@convertOptions.rotate_angle = 90
@convertOptions.use_pdf = false
@settings.convert_options = @convertOptions
@settings.output_path = "word-to-images"
@request = GroupDocsConversionCloud::ConvertDocumentRequest.new(@settings)
@result = @apiInstance.convert_document(@request)
puts("Word Docx successfully converted to gif format. ")
# How to convert word docx to jpeg
# Getting instance of the ConvertAPI
@apiInstance = GroupDocsConversionCloud::ConvertApi.from_keys(@app_sid, @app_key)
# Initialize and set convert settings
@settings = GroupDocsConversionCloud::ConvertSettings.new()
@settings.storage_name = @storage_name
@settings.file_path = "word-to-images/one-page.docx"
@settings.format = "jpeg"
# Set Docx LoadOptions
@loadOptions = GroupDocsConversionCloud::DocxLoadOptions.new()
@loadOptions.password = "password"
@settings.load_options = @loadOptions
@convertOptions = GroupDocsConversionCloud::JpegConvertOptions.new()
@convertOptions.grayscale = true
@convertOptions.from_page = 1
@convertOptions.pages_count = 1
@convertOptions.quality = 100
@convertOptions.rotate_angle = 90
@convertOptions.use_pdf = false
@settings.convert_options = @convertOptions
@settings.output_path = "word-to-images"
@request = GroupDocsConversionCloud::ConvertDocumentRequest.new(@settings)
@result = @apiInstance.convert_document(@request)
puts("Word doc successfully converted to jpeg. " + (@result).to_s)
# How to convert word docx to jpg
# Getting instance of the Convert API
@apiInstance = GroupDocsConversionCloud::ConvertApi.from_keys(@app_sid, @app_key)
# Initialize image convert settings
@settings = GroupDocsConversionCloud::ConvertSettings.new
@settings.storage_name = @storage_name
@settings.file_path = "word-to-images/one-page.docx"
@settings.format = "jpg"
@convertOptions = GroupDocsConversionCloud::JpgConvertOptions.new
@convertOptions.from_page = 1
@convertOptions.pages_count = 2
@settings.convert_options = @convertOptions
@settings.output_path = "word-to-images"
@request = GroupDocsConversionCloud::ConvertDocumentRequest.new(@settings)
# Convert to jpg
@response = @apiInstance.convert_document(@request)
puts("Word docx successfully converted to jpg format.")
# How to convert word docx to png
# Getting instance of the Convert API
@apiInstance = GroupDocsConversionCloud::ConvertApi.from_keys(@app_sid, @app_key)
# Initialize convert settings
@settings = GroupDocsConversionCloud::ConvertSettings.new()
@settings.storage_name = @storage_name
@settings.file_path = "word-to-images/one-page.docx"
@settings.format = "png"
# Set Word Docx LoadOptions
@loadOptions = GroupDocsConversionCloud::DocxLoadOptions.new()
@loadOptions.password = "password"
@settings.load_options = @loadOptions
@convertOptions = GroupDocsConversionCloud::PngConvertOptions.new()
@convertOptions.grayscale = true
@convertOptions.from_page = 1
@convertOptions.pages_count = 1
@convertOptions.quality = 100
@convertOptions.rotate_angle = 90
@convertOptions.use_pdf = false
@settings.convert_options = @convertOptions
@settings.output_path = "word-to-images"
@request = GroupDocsConversionCloud::ConvertDocumentRequest.new(@settings)
@result = @apiInstance.convert_document(@request)
puts("Word Docx successfully converted to png image. ")

You can convert Word DOCX to image formats programmatically on the cloud. In this article, you will learn how to convert Word DOCX to image formats using REST API in Ruby.

The following topics are covered in this article:

  1. High Performance Word to Images Conversion REST API and Ruby SDK
  2. Convert Word to JPEG using REST API in Ruby
  3. How to Convert Word to JPG using Advanced Options
  4. How to Convert DOCX to PNG using REST API in Ruby
  5. Convert Word DOCX to GIF in Ruby using REST API
  6. Free Online Word to Image Converter
# Load the gem in your ruby application for http://api.groupdocs.cloud
require 'groupdocs_conversion_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"
@storage_name = "my-local-storage"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment