Develop Word to PDF Converter Online using Ruby Cloud SDK. Perform DOCX to PDF or DOC to PDF online

How to convert docx to pdf? | Best word to pdf converter | Aspose.Words Cloud Ruby SDK.

How to convert docx to pdf - Top word to pdf converter

Overview

DOCX is a well-known format for Microsoft Word documents and was introduced with Microsoft Word 2007. Docx is based on open XML and Docx files can be opened with Word 2007. While, PDF is a Portable Document Format for representing documents. It is a versatile file format developed by Adobe Systems and can have any number of fonts and images. It provides an easy, reliable way to create, present document files and transfer of printer-ready output.

Do you want to convert a DOCX file to a PDF file? Many word document processing applications provide the capabilities to convert Word to Pdf file format. But this whole process requires an effort to install an application as well as licensing cost. But why to pay for the whole product licensing when you only need to perform one single operation. Furthermore, bulk conversion operations cannot be performed with such market available software. In all such cases, Aspose.Words Cloud API comes into action to perform an easy and quick file format processing.

Aspose.Words DOCX to PDF Converter app instantly converts your DOCX files in PDF format with the help of open-source Ruby SDK. These SDKs and tools are maintained by the developers at Aspose.Words and provide the easiest way to integrate Aspose.Words Cloud API with your application. You can easily convert your DOCX files to PDF file with this free Ruby SDK tool. Aspose.Words helps you to convert DOCX Documents into PDFs instantly with high fidelity. Using the Aspose Cloud REST API it is possible to perform advanced file format processing. Moreover, you can find generated ready-to-use cURL code snippet example at the bottom of this page.

Aspose supports many options for integrating document automation into applications of several platforms and programming languages. In this article, we are going to discuss following topics in detail. Let’s Explore.

DOC to PDF Conversion API

Aspose.Words document converter allows you to convert your files from DOCX to PDF in high quality. Aspose.Words Cloud API supports a lot of different file formats like DOC, DOCX, DOCM, DOTX, RTF, ODT, OTT and many more. It is an exciting solution to create, manipulate and transform leading Word document formats using aspose conversion technology. You will get very accurate conversion results quickly.

With the help of this API, we can perform Word to PDF as well as conversion operations to other formats without using MS Office automation or any other dependencies. In order to facilitate our customers, specific programming language SDKs were developed so that you can access the API right within your application code. In this article, our emphasis is on Aspose.Words Cloud SDK for Ruby by enabling the Ruby developers to implement Word document processing capabilities in Ruby applications quickly and easily, with zero initial cost.

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 for word docx to pdf converter.

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.

Aspose.Cloud Account Subscription Explained

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 Doc to Pdf 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 as shown in the image below.

Document to pdf converter

Now 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.

The most popular document docx to pdf converter application

Now, scroll down towards the Client Credentials section to copy Client Id and Client Secret as shown in the image below.

client credentials for the most popular document docx to pdf converter ruby application

These Client Credentials will be used to make API Calls to the Aspose.Words cloud APIs for DOCX to PDF converter. Next, we will see how to convert a Word to PDF by using Aspose.Words cloud SDK for Ruby.

Word to PDF Converter in Ruby

Follow the instructions given below to perform the MS Word files DOCX to PDF conversion using Ruby SDK for 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 DOCX file to cloud storage using UploadFileRequest() method
  5. Now, create an object of ConvertDocumentRequest() which takes input DOCX name, resultant format as arguments
  6. Finally, initiate DOCX to PDF conversion process with the convert_document() method.

As a result mysample.pdf will be saved at the root of project folder.

Word to PDF using cURL Commands

Now let’s examine how to convert a word document to pdf using cURL. cURL command line tool is used to access REST APIs to and from a server. Since Aspose.Words Cloud APIs are developed as per REST principles, so we can use these Cloud APIs to do the conversion operations. To perform conversion, we will generate JSON Web Token (JWT) based on ClientID and ClientSecret retrieved from Aspose.Cloud dashboard. Please execute the command in the terminal to generate the JWT token like below.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=######-####-####-####-######&client_secret=#########################" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now we are going to use the JWT token in below command to convert the Word to PDF format where the input DOCX file should be available on cloud storage. Then outPath parameter shows the location for the resultant PDF document and the format is the format of the resultant pdf file. GetDocumentWithFormat API is for document conversion and doc-to-pdf.doc file is rendered to PDF format successfully. You can check saved file with doc-to-pdf.pdf name in cloud storage.

curl -X GET "https://api.aspose.cloud/v4.0/words/test_multi_pages.docx?format=pdf&outPath=doc-to-pdf.pdf" \
-H  "accept: application/octet-stream" \
-H  "Authorization: <PASTE HERE JWT Token>"

Conclusion

In the above article, all the details related to Word to PDF / DOCX to PDF / DOC to PDF are explained in a step by step manner using Aspose.Words Cloud SDK for Ruby. Aspose Cloud SDKs are open-source (published under MIT license) and the complete code of Aspose.Words cloud SDK for Ruby is available on GitHub.

If you have any questions, suggestions or comments about best DOCX to PDF Converter, Feel free to visit support forum. You can follow us on social media Facebook, LinkedIn, and Twitter.

Explore

We also recommend visiting following related links: