Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert PDF to HTML pages using REST API in Ruby

Learn how to convert PDF document to HTML file in Ruby using cloud REST API:

The following topics shall be covered in this article:

  1. PDF to HTML Conversion REST API – Installation
  2. PDF to HTML Conversion using REST API in Ruby
  3. How to Convert Range of Pages from PDF to HTML
  4. How to Convert Specific Pages of PDF to HTML
  5. Online PDF to HTML Converter for Free
# This code example demonstrates how to convert specific pages of PDF to HTML in Ruby
# Create convert api instance
@convert_api = GroupDocsConversionCloud::ConvertApi.from_keys(@client_id, @client_secret)
# Create convert settings
@settings = GroupDocsConversionCloud::ConvertSettings.new
@settings.storage_name = @storage_name
@settings.file_path = "pdf-to-html/pdf-pages.pdf"
@settings.format = "html"
@convertOptions = GroupDocsConversionCloud::HtmlConvertOptions.new
# The page indexes of the specific pages to be converted
@convertOptions.pages = [1, 5]
@settings.convert_options = @convertOptions
@settings.output_path = "pdf-to-html"
# PDF convert specific pages to HTML
@response = @convert_api.convert_document(GroupDocsConversionCloud::ConvertDocumentRequest.new(@settings))
puts("PDF certain pages converted to HTML successfully.")
# This code example demonstrates how to convert range of pages from PDF to HTML in Ruby
# Create convert Api instance
@convert_api = GroupDocsConversionCloud::ConvertApi.from_keys(@client_id, @client_secret)
# Create convert settings
@settings = GroupDocsConversionCloud::ConvertSettings.new
@settings.storage_name = @storage_name
@settings.file_path = "pdf-to-html/pdf-pages.pdf"
@settings.format = "html"
@convertOptions = GroupDocsConversionCloud::HtmlConvertOptions.new
@convertOptions.from_page = 1
# Number of pages to convert
@convertOptions.pages_count = 3
@convertOptions.fixed_layout = true
@settings.convert_options = @convertOptions
@settings.output_path = "pdf-to-html"
# Convert pdf to html using advance options
@result = @convert_api.convert_document(GroupDocsConversionCloud::ConvertDocumentRequest.new(@settings))
puts("PDF file converted to HTML using advance options.")
# This code example demonstrates how to convert pdf document to html web pages.
# Create ConvertApi instance
@convert_api = GroupDocsConversionCloud::ConvertApi.from_keys(@client_id, @client_secret)
# Prepare convert settings
@settings = GroupDocsConversionCloud::ConvertSettings.new
@settings.storage_name = @storage_name
@settings.file_path = "pdf-to-html/pdf-pages.pdf"
@settings.format = "html"
@settings.output_path = "pdf-to-html"
# Convert pdf to html
@result = @convert_api.convert_document(GroupDocsConversionCloud::ConvertDocumentRequest.new(@settings))
puts("PDF file successfully converted to HTML.")
# Get your client_id and client_secret from https://dashboard.groupdocs.cloud after free registration.
# Load the gem in your ruby application for http://api.groupdocs.cloud
require 'groupdocs_conversion_cloud'
@client_id = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
@client_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Set your storage name
@storage_name = "test-internal-storage"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment