Word is one of the popular formats for sharing and printing documents. We often need to convert word documents to different image formats. It is better to use already developed specialized tools that provide an easily maintainable, flexible conversion solution to your needs. Ruby SDK of GroupDocs.Conversion provides the best way to convert Word DOCX to JPG, PNG and GIF files in seconds. It is 100% free, secure and easy to use Ruby SDK for files conversion. It allows converting documents of supported formats to image programmatically on the cloud
In this article, we will learn how to convert word to image using REST API in Ruby. The following topics shall be covered in this article:
- High Performance Word to Images Conversion REST API and Ruby SDK
- Convert Word to JPEG using REST API in Ruby
- How to Convert Word to JPG using Advanced Options
- How to Convert DOCX to PNG using REST API in Ruby
- Convert Word DOCX to GIF in Ruby using REST API
- Free Online Word to Image Converter
High Performance Word to Images Conversion REST API and Ruby SDK
For converting JPG, PNG and GIF images to Ruby, we will be using the Ruby SDK of GroupDocs.Conversion Cloud API. You can install it using the following command in the console:
gem install groupdocs_conversion_cloud
Firstly, get your Client ID and Secret from the dashboard before following the below mentioned steps. Once you have your ID and secret, add below code in your application as shown below:
Convert Word to JPEG using REST API in Ruby
We can convert word to images by following the simple steps given below: Firstly, you need to upload the docx file to the cloud using the following code sample: As a result, the uploaded file will be available in the files section of the dashboard on the cloud. Now, you can convert Word to JPEG format programmatically by following the steps given below:
- Firstly, create an instance of the ConvertApi.
- Next, create an instance of the ConvertSettings.
- Then, set the word file path and storage name.
- Also, assign “jpeg” as output image format.
- Create an instance of the DocxLoadOptions
- Set the word file password and load_options.
- Create an instance of the JpegConvertOptions.
- Define the grayscale, from_page, pages_count, quality, rotate_angle and use_pdf values.
- Set convertOptions to settings.
- Now, provide the output file path.
- After that, create ConvertDocumentRequest with ConvertSettings as argument.
- Finally, call the ConvertApi.convert_document() method with ConvertDocumentRequest to save the converted file.
The following code sample shows how to convert word document to JPEG image using REST API in Ruby.
The above code sample will save the converted JPEG file on the cloud. You can also download it by adding the download file API.
How to Convert Word to JPG using Advanced Options
We can convert Word Doc to JPG format using advanced settings programmatically by following the steps given below:
- Create an instance of the ConvertApi.
- Then, create an instance of the ConvertSettings.
- Also, set the storage name and word file path.
- Set “jpg” as output image format.
- Create an instance of the JpgConvertOptions.
- Define from_page and pages_count values.
- Set convertOptions to settings.
- Now, provide the output file path.
- After that, create ConvertDocumentRequest with ConvertSettings as argument.
- Finally, call the ConvertApi.convert_document() method with ConvertDocumentRequest to save the converted file.
The following code example shows how to convert word to JPG image with advanced convert options.
How to Convert DOCX to PNG using REST API in Ruby
You can convert Word Docx to PNG format programmatically by following the steps given below:
- Create an instance of the ConvertApi.
- Next, create an instance of the ConvertSettings.
- Then, set the word file path and storage name.
- Also, set “png” as output image format.
- Create an instance of the DocxLoadOptions
- Set the word file password and load_options.
- Create an instance of the PngConvertOptions.
- Define the grayscale, from_page, pages_count, quality, rotate_angle and use_pdf values.
- Set convertOptions to settings.
- Now, provide the output file path.
- After that, create ConvertDocumentRequest with ConvertSettings as argument.
- Finally, call the ConvertApi.convert_document() method with ConvertDocumentRequest to save the converted file.
The following code example shows how to convert word to PNG format using REST API in Ruby.
Convert Word DOCX to GIF in Ruby using REST API
We can convert Word Docx to JPG programmatically by following the steps given below:
- Create an instance of the ConvertApi.
- Next, create an instance of the ConvertSettings.
- Then, set the word file path and storage name.
- Also, set “gif” as output image format.
- Create an instance of the DocxLoadOptions
- Set the word file password and load_options.
- Create an instance of the GifConvertOptions.
- Define the grayscale, from_page, pages_count, quality, rotate_angle and use_pdf values.
- Set convertOptions to settings.
- Now, provide the output file path.
- After that, create ConvertDocumentRequest with ConvertSettings as argument.
- Finally, call the ConvertApi.convert_document() method with ConvertDocumentRequest to save the converted file.
The following code sample shows how to convert word Docx to GIF file using REST API in Ruby. Please follow the steps mentioned earlier to upload a file.
Free Online Word to Image Converter
Please try the following free online JPG, PNG and GIF conversion tool, which is developed using the above API https://products.aspose.app/words/conversion/docx-to-image.
Conclusion
In this article, we have learned how to convert word to image formats on the cloud. Now you know how to:
- convert word documents to jpeg/jpg using REST API in ruby
- how to convert word docx to png image format using ruby
- convert word docx to gif file format using REST API in ruby
You can learn more about GroupDocs.Conversion 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 questions about word docx to image converter, please feel free to ask us on the Forum.