Convert Word to HTML using Ruby Cloud SDK. Develop DOC to HTML Document Converter online.

Convert Word to HTML in Ruby

How to Convert Word to HTML - DOC to HTML Document in Ruby Online

Overview

Word to HTML is one of the most widely used document file format that contains text, images, data etc. Converting the Word to HTML using Aspose.Words Conversion Services API is very easy and simple process. There are plenty of benefits of converting Word to HTML documents using Aspose.Words Cloud API. Aspose.words Cloud REST API performs an easy and quick file format conversions.

You can quickly convert a Word to HTML file in high quality using Aspose Cloud API. Use our Word to HTML that helps developers to use it on their sites. Our Word converter is the best choice for your file conversion needs to turn a Word to HTML file. In this article, we are will explain how to use best Word to HTML converter tool using aspose file format conversion API.

Word to HTML Conversion API

Aspose.Words Cloud empowers you to convert Word to HTML in a conveneint and reliable manner. You can bring back a Word to HTML format by converting it using DOCX to HTML API. Aspose Words Ruby SDK will allow you to maintain the document structure. You can then open the document in html file and edit it. Aspose.Words file conversion API offers one of the most advanced Word document to HTML conversions efficiently. Aspose.Words file conversion Word to HTML preserves the layouts. This saves your alot of time and effort of retyping.

Our Aspose.Words APIs for Doc file to HTML file can easily produce high quality results when converting Word to HTML file. After conversion, you can easily edit the Html file according to your needs. This Aspose Cloud API meets the needs when processing Word documents for business, education and many more. Aspose Words Cloud API is easy to process with fast working speed, text formatting and high accuracy of file format conversion.

How to Install Aspose.Words Ruby SDK?

In order to use Ruby SDK for communicating with the Aspose.Words Cloud REST API, we first need to install it on our system. Ruby SDK is available to download with zero initial cost as RubyGem (recommended) and from GitHub. Once you have Ruby runtime configured, please execute the following command in the terminal to perform the quick and easy installation in a Ruby application.

gem 'aspose_words_cloud', '~> 22.3'
# or install directly
gem install aspose_words_cloud

But before you proceed with the installation of Aspose.Words Cloud SDK for Ruby 2.6 or later, you need to install the following dependency packages on your system.

# Following are the runtime dependencies to setup aspose_words_cloud
faraday 1.4.3 >= 1.4.1
marcel 1.0.1 >= 1.0.0
multipart-parser 0.1.1 >= 0.1.1
# Development dependencies is
minitest 5.14.4 ~> 5.11, >= 5.11.3

This SDK for Ruby supports more than 20 document-related formats with full read and write access. For more details, please visit aspose cloud documentation website.

Create Aspose.Cloud API Credentials

After installing all dependency packages of Ruby environment, the next step is to obtain ClientID and ClientSecret details to make calls to the Aspose.Words cloud APIs for Word to HTML conversion. There are two options to consume the REST APIs directly via some rest client like cURL or using cloud SDKs. So, the first step is to create an account by navigating Aspose.Cloud dashboard. If you have Google or Microsoft account then simply click Google or Microsoft button to Sign Up. Otherwise click Sign Up link to create new account by providing the required information.

After sign into the cloud space dashboard and click the Applications tab in the left sidebar. Now scroll down, click Create New Application button. Next, create your new application by selecting your default storage as shown in the image below. You can also configure third-party storage to upload your data files by following how to configure 3rd party cloud storage guide. Now, scroll down towards the Client Credentials section to copy Client Id and Client Secret as shown in the image below.

These Client Credentials will be used to make API Calls to the Aspose.Words cloud APIs for Word to HTML Document converter.

Aspose.Words has a user-friendly interface where you can test APIs in real-time for Word to HTML converter from the UI. Here, you can set different parameters, insert data and upload files to test the file conversion features. Moreover, you can instantly convert a Word to HTML file at very high fidelity using our Cloud API. But our free online word to html converter application is also available for any device and browser as shown in the below image.

Free online converter - docx to html

Next, we will see how to convert a Word to HTML by using Aspose.Words cloud SDKs for Ruby.

Convert Word to HTML in Ruby

The following code below illustrates how simple it is to convert Word to HTML documents. Follow the instructions below to do the MS Word to HTML file conversion using Aspose Ruby SDK in ruby on rails application.

  1. The first step is to create ruby variables holding ClientID and ClientSecret copied from the aspose cloud dashboard.
  2. At second, create AsposeWordsCloud configuration and pass ClientID, ClientSecret values.
  3. Third step is to create an instance of WordsAPI
  4. Next, upload source document file to cloud storage using UploadFileRequest() method
  5. Finally, Save document conversion request parameters and convert document to html document

If your current virtual host configuration doesn’t match the example, update it accordingly. When you’re done, save the file and quit the editor. Then, run the following command to validate your changes:

# Load the gem, For complete list please visit https://github.com/aspose-words-cloud/aspose-words-cloud-ruby
require 'aspose_words_cloud'
# How to convert Word to HTML programmatically.
# Get AppKey and AppSID credentials from https://dashboard.aspose.cloud/applications
@AppSID = “###-######-####-####-##########”
@AppKey = “#############################”
# Associate Configuration properties with WordsApi
AsposeWordsCloud.configure do |config|
config.client_data[‘ClientId’] = @AppSID
config.client_data[‘ClientSecret’] = @AppKey
end
# Create an instance of WordsApi
@words_api = WordsAPI.new
# Input DOCX file
@fileName = "sample.docx"
# Final file format
@format = "html"
@destName = "word-to-html.html"
# Upload original document to Cloud Storage
@words_api.upload_file UploadFileRequest.new(File.new(@fileName, 'rb'), @fileName, nil)
@save_options = SaveOptionsData.new(
{
:SaveFormat => @format,
:FileName => @destName
})
# Save document conversion request parameters.
@request = SaveAsRequest.new(@fileName, @save_options, nil, nil, nil, nil, nil)
@out_result = @words_api.save_as(@request)
# Print result response in console
puts("word successfully converted to html file" + (@out_result).to_s )
# End word conversion example.

As a result word-to-html.html will be saved at the root of cloud directory. That’s it

Conclusion

In summary, we have explored the steps for how to convert word to html file using Aspose.Words Cloud SDK for Ruby. Aspose.Words Cloud SDKs are open-source tools and the complete code of SDK is available on GitHub repository. Feel free to download Cloud SDK into your project and perform document conversions for your needs.

If you have any questions, suggestions or comments, Feel free to visit our community support forum. For more file conversion related articles, you can follow us on our social media accounts Facebook, LinkedIn, and Twitter.

We also recommend visiting following links for additional help and support: