Convert PDF to HTML using REST API in Ruby

Convert PDF to HTML using REST API in Ruby

You may need to convert a PDF file into HTML because HTML is generally much better for providing information via the web. In order to perform this pdf to html conversion by keeping format programmatically, this article will cover how to convert PDF to HTML using REST API in Ruby. Furthermore, you will also learn how to use additional options for converting PDF to HTML using online pdf to html converter free download library.

PDF offers to share and print read-only documents without losing documents formatting. We can easily convert PDF documents to HTML web pages and view them in any browser. Let’s learn how to convert pdf to html format using Ruby.

The following topics shall be covered in this article:

PDF to HTML Conversion REST API - Installation

For converting pdf to html format, we will be using the Ruby SDK of GroupDocs.Conversion Cloud API. You can install PDF document to HTML converter free download library, using the following command in the console:

gem install groupdocs_conversion_cloud

This PDF to HTML converter software is available free to download. Now, please get your Client ID and Secret from the GroupDocs Dashboard before following the below mentioned steps. Once you have your Client ID and Client Secret, add these in the ruby application code as shown below:

Next, let’s explore how to convert a pdf to html format step by step using REST API in Ruby.

PDF to HTML Conversion using REST API in Ruby

We can convert pdf file to html format programmatically by following the simple steps given below:

  • Firstly, create an instance of the ConvertApi
  • Now, create convert settings instance using ConvertSettings
  • Next, provide the files storage name
  • Set the input PDF file path and the output file format as “html”
  • Then, provide the output path name
  • After that, create the ConvertDocumentRequest with ConvertSettings as an argument
  • Finally, turn pdf to html by calling the convert_document() method with ConvertDocumentRequest

The following code sample shows how to change pdf to html format in Ruby.

Finally, the above code sample will save the HTML file on the cloud. This is the best way to convert pdf to html document.

How to Convert Range of Pages from PDF to HTML

We can convert range of pages of a PDF document to HTML by following the steps given below:

  • First, create an instance of the ConvertApi
  • Now, create convert settings instance using ConvertSettings
  • Next, provide the files storage name
  • Set the input PDF file path and the output file format as “html”
  • Create an instance of the HtmlConvertOptions
  • Set the from_page, pages_count and fixed_layout convert options
  • Then, set convert_options and output_path values
  • After that, create the ConvertDocumentRequest with ConvertSettings as an argument
  • Finally, convert pdf to html code online by calling the convert_document() method with ConvertDocumentRequest

The following code sample shows how to convert a range of pages from a PDF document to an HTML file using Ruby.

Finally, the above code sample will save document after converting from pdf to html online on the cloud.

How to Convert Specific Pages of PDF to HTML

We can convert specific pages of a PDF document to HTML using best pdf to html converter online with images by following the steps given below:

  • First, create an instance of the ConvertApi
  • Now, create convert settings instance using ConvertSettings
  • Next, provide the files storage name
  • Set the input PDF file path and the output file format as “html”
  • Create an instance of the HtmlConvertOptions
  • Provide the pages collection html convert option
  • Then, set convert_options and output_path values
  • After that, create the ConvertDocumentRequest with ConvertSettings as an argument
  • Finally, convert a pdf to html file by calling the convert_document() method with ConvertDocumentRequest

The following code sample shows how to export certain pages of a PDF document to HTML file using Ruby.

Finally, the above code sample will convert pdf to html with images on the cloud. There is an online pdf to html code converter as explained below.

PDF to HTML Online Conversion Tool

How to Convert PDF to HTML Online Free? Groupdocs.Conversion provides a free online pdf to html converter tool for you to change your PDF to HTML format. Simply select the file you want to convert, and use the best pdf to html converter online free to turn your PDF file into an HTML file. It has been developed using the Groupdocs.Conversion online pdf to html API.

Conclusion

In this article, you have learned:

  • how to convert pdf to html without losing formatting in Ruby;
  • how to convert pdf to html file by range in Ruby;
  • converting specific PDF pages to HTML format;
  • online convert pdf to html for free;

Besides, you can learn more about GroupDocs.Conversion file format conversion API using the documentation.

Ask a question

If you have any queries regarding how to convert pdf file to html format, please feel free to ask us at Free Support Forum

See Also