Converting Word Documents to TIFF Images Using Ruby.
Overview
Microsoft Word document format (DOCX, DOC) has plethora of benefits as it provides editability, compatibility, collaboration, formatting capabilities, ease of use & productivity, makes it a popular choice for document processing tasks. In fact, the Word document format is a valuable resource for businesses and organizations that need to create, edit, and share documents. However, the TIFF (Tagged Image File Format) is a widely used format for storing raster images, including photographs and scanned documents. One of the main purposes of TIFF is to provide a flexible and robust format for exchanging and archiving high-quality images. Lossless compression, high quality, versatility, long-term archiving and interoperability are among its prominent benefits.
So, converting a Word documents to TIFF images offers several benefits, including image preservation, compatibility, ease of printing and manipulation, document archiving, and space savings.
- What is Word to TIFF Conversion API?
- Word to TIFF Conversion in Ruby
- DOC to TIFF using cURL Commands
What is Word to TIFF Conversion API?
Aspose.Words Cloud is a cloud-based document processing solution offering the capabilities of creating, editing, and converting documents in the cloud. The API supports multiple file formats, including Microsoft Word (DOC, DOCX), PDF, HTML, and more. Similarly, it is also capable of converting Word DOCX to TIFF images, while ensuring a lossless compression & high image quality, as it makes them ideal for photograph printouts.
How to Install the Ruby Cloud SDK
Once the ruby runtime is configured, the first step in SDK utilization is its installation. It’s available for download over RubyGem (recommended) and GitHub. But, before we proceed with SDK installation, we need to have the following dependency packages installed on our 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
Now, please execute the following command in the terminal to perform a quick installation of aspose_words_cloud gem.
gem 'aspose_words_cloud', '~> 22.3'
# or install directly
gem install aspose_words_cloud
Now the next important step is to obtain ClientID and ClientSecret details by visiting Aspose.Cloud dashboard. If you do not have an existing account, simply sign up using create new account link and provide a valid email address. Now, we are good to begin with the Word to TIFF conversion operation.
Word to TIFF Conversion in Ruby
The following section explains the steps on how to convert a Word to TIFF in a ruby application.
- The first step is to create the ruby variables holding ClientID and ClientSecret details (as mentioned on Aspose Cloud Dashboard).
- Secondly, create AsposeWordsCloud configuration object and pass ClientID, ClientSecret details as arguments.
- The third step is to create an instance of WordsAPI class
- Now we need to upload the input Word document to Cloud storage using UploadFileRequest() method
- Finally, convert DOCX to TIFF image using save_as_tiff(..) method which takes SaveAsTiffRequest object as an argument
Once the code is successfully executed, a resultant word-to-tiff.tiff will be saved in the cloud storage.
DOC to TIFF using cURL Commands
DOC to TIFF conversion using cURL commands allows you to convert Microsoft Word documents (DOC, DOCX) into TIFF images. This conversion is performed by making API requests to Aspose.Words Cloud, using the cURL commands. The API accepts the DOC or DOCX file as an input and returns the resultant TIFF image. As the cURL commands can be executed from the command line terminal, it enables the automation of the complete conversion process. Also, the cURL commands used for the conversion will vary depending on the specific API being used, but typically involves sending an HTTP request to the API with the input document and other necessary parameters, and receiving the resultant TIFF image in the response.
Now, as a prerequisite for this approach, we need to first generate a JWT token based on our personalized client credentials.
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Once the token has been generated, please use the following command to convert DOC to TIFF image. Please note, this commands expects the input Word (DOC) to be already available in the cloud storage. After the successful conversion, the resultant TIFF is also stored in the cloud storage.
curl -v -X GET "https://api.aspose.cloud/v4.0/words/input.doc?format=TIFF&outPath=converted.tiff" \
-H "accept: application/octet-stream" \
-H "Authorization: Bearer <JWT Token>"
NOTE:- Looking for an online Word to TIFF converter ? Please try using our Free Online Converter
Conclusion
In this article, we have discussed the details on converting Word documents to TIFF images, as it’s a common need from businesses and organizations that work with a large volume of documents. By leveraging the power of Ruby and the flexibility of Aspose.Words Cloud, it has become possible to automate the whole conversion process. This eventually reduces the time and effort required to convert the large volumes of documents.
To further facilities our users, the complete source code of Ruby Cloud SDK is published on GitHub repository. Also, we do recommend exploring the developer’s guide to learn about other exciting features of the API. Furthermore, you may also consider using the API through a SwaggerUI Interface directly within a web browser.
Lastly, in case you have any questions or suggestions, please feel free to contact us via our free product support forum.
Related Topics
We highly recommend visiting the following links to learn about: