Convert DOC to HTML using a REST API

With Doc Conversion API, you can convert easily between document formats, converting between Word DOC to HTML is a very important conversion for a number of reasons.


Conversion chart showing different types of conversions, highlighting Doc to HTML

It will allow you to turn an existing Word document into an HTML page, this will eliminate the risk of losing or editing any document content. With this conversion, you no longer need to worry about downloading documents and having them in a single location, you can access them from any device (mobile phones, tablets, computers), on any platform, with no extra software.

While there are a number of ways to convert a Word DOC to an HTML page, there has not been a single perfect method to do this both easily and efficiently, and without compromising on formatting or fidelity. But that’s where Doc Conversion API comes for the rescue, as it provides a very simple, reliable REST API that you can call into and execute with simple code, and quickly convert your Word Documents into fully formatted HTML pages.

Using the REST API to convert Doc to HTML (CURL)

Doc Conversion API is compatible with all programming languages and frameworks, you can find a list of code examples here.

You can simply convert from DOCto HTML by making a POST request, using the below URL Along with your APP credentials (Application ID and Secret Key):

https://api.docconversionapi.com/convert?outputFormat=html

To make the following curl request:

curl --request POST \
 --url 'https://api.docconversionapi.com/convert?outputFormat=html' \
 --header 'X-ApplicationID: <Your_Application_ID>' \
 --header 'X-SecretKey: <Your_Application_SecretKey>' \
 --header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
 --form inputFile=undefined \
 --form optionsJSON=

Where:
X-ApplicationID
is your DCA Application ID

X-SecretKey      is your DCA Secret key

OutPutFormat is HTML

InputFile         is the file you would to like to convert

optionsJSON is a JSON String containing any additional options relevant to the conversion type.

Using the REST API to convert Doc to HTML (PHP)

Doc Conversion API is compatible with most programming languages and frameworks, you can find a list of code examples here.

For this PHP example, we’re using a direct URL for our word document (the document we’re converting) for simplicity, you can also upload documents to the service.

We’re going to be using this example:

http://homepages.inf.ed.ac.uk/neilb/TestWordDoc.doc

Example of the original test Doc to be converted to HTML

We’re going to create a simple PHP page that reads the Doc file from a URL, and converts this file into an HTML page:

PHP code to show how to use REST API to convert from Doc to HTMLDownload this page / View this page

This code will execute the conversion, and display the Word Doc content as an HTML page.

Output result from the Doc to HTML conversion

If you have any questions or need any further help, please contact us at [email protected]

Amazon S3 and Azure Storage Now Supported

You can now be fully in charge of your own file storage within Doc Conversion API  our new Linked Storage feature, supporting Amazon S3 and Azure Storage.

Doc_Conversion_API

By default, at Doc Conversion Api we store files in our secure cloud servers, however, if  you already have a cloud storage solution in place and you would like to integrate it with Doc Conversion API, you can now easily do that.

You no longer need to send your files to our servers, everything can be done using your own storage resources. You are now able to import files from your cloud storage, convert, process, or merge these files, and export them back to your cloud storage, without having to use our servers, that way you ensure that the whole process is compatible with your internal security standards.

Our Linked Storage feature will allow you to add more than one service, and simultaneously switch between them in a simple, efficient way. You can also manage your linked storage accounts at any time; edit, rename, and delete accounts easily through your dashboard. 

Accounts


Doc Conversion API currently supports the two main cloud storage providers, Amazon S3 and Azure Storage.

Adding Linked Storage Accounts:

Amazon S3:

You can easily configure your S3 bucket as a storage backend by providing your Amazon key ID, key secret, and bucket name. Once you have these details, adding your account is as simple as a few steps.

1. Click on “Add New Storage Account”

2. Select “Amazon”

Screen Shot 2018-09-17 at 12.08.55 PM

3. Fill in your details.

Amazon

4. Click on “Add Account” to finish.

Azure:

Similarly, adding an Azure container can be easily done from the “Linked Storage” section in your dashboard. You just need your Azure account name, account key and container name.

You can read here about how to obtain your Azure storage credentials. Once you have your credentials ready, adding your account is super simple.

1. Click on “Add New Storage Account”.

2. Select “Azure”

Screen Shot 2018-09-17 at 12.05.16 PM

3. Fill in your details

Azure 1

4. Click on “Add Account” to finish.

Using Linked Storage Accounts:

Our aim is to make it easier for you to read, convert, and write files, using our REST API, you can now do all of the above with a few simple lines of code.


Import files:

To import the files you would like to convert from your storage service, you simply need to add a parameter to the body of your HTTP request, this is  named “inputFile”, and should be assigned the following value:

storage://Local_account_name/bucket_name/FilePath

Local_account_name: is the custom name of the your storage account in your dashboard.

Bucket_name: is the name of your bucket or blob.

FilePath: is the path of the file you’d like to import.

Export files:

After converting your files, you can save them directly into your storage service, this can be done by adding a field called “saveTo”, and assigning the following value to it.

<code>storage://Local_account_name/bucket_name/FilePath+Name</code>

Local_account_name: is the custom name of the your storage account in your dashboard.

Bucket_name: is the name of your bucket or blob.

FilePath+Name: This is the path where you would you like to save the converted file, along with the file name.

If you need any further help with setting up your storage services, please email us on [email protected], and we will be happy to help.

Get Your Embedded Document Widget Code

Once you’ve installed our HTML5 Document Viewer for WordPress you’ll need your Embedded Document Widget Code to place into the plugin so you can show your documents off to your audience.

The steps below will walk you through the process.

Step 1 - Visit This Link
Step 1 – Visit This Link
Step 2 - Click The Create New Account Link
Step 2 – Click The Create New Account Link
Step 3 - Complete The Registration Form And Click Register Account
Step 3 – Complete The Registration Form And Click Register Account
Step 4 - LogIn With Your New Account Details
Step 4 – LogIn With Your New Account Details
Step 5 - Upload A New Document Or Use One Of The Included Examples
Step 5 – Upload A New Document Or Use One Of The Included Examples
Step 6 - Convert The Document From Its Native Format To PDF
Step 6 – Convert The Document From Its Native Format To PDF
Step 7 - Click On The HTML5 Viewer Icon That Appears Alongside The Newly Created PDF
Step 7 – Click On The HTML5 Viewer Icon That Appears Alongside The Newly Created PDF
Step 8 - Copy The HTML5 Viewer Code
Step 8 – Copy The HTML5 Viewer Code
Step 9 - Paste The HTML5 Viewer Code Into The WordPress Plugin Dialog
Step 9 – Paste The HTML5 Viewer Code Into The WordPress Plugin Dialog

Once you’ve done the above and published (or previewed) your post you’ll see your nice new HTML5 viewer showing your document content on your own website!

If you need anything from us, just get in touch, we’d love to start a conversation with you.

Install Our HTML5 Document Viewer WordPress Plugin

Installing the Doc Conversion API HTML5 Document Viewer on WordPress only takes a few seconds.

This article shows the manual option of installing, an alternative option is installing from the WordPress Plugins directory which will be covered in a separate article.

Step 1 - Plugins
Step 1 – Go To Your WordPress Sites Plugins Section
Step 2 - Choose The Upload Plugin Option
Step 2 – Choose The “Upload Plugin” Option
Step3 - Upload The Plugin And Click Install Now
Step 3 – Upload The Plugin And Click “Install Now”

The Doc Conversion API WordPress Plugin can be downloaded from this location.

Step 4 - Once Uploaded Activate The Plugin
Step 4 – Once Uploaded Activate The Plugin
Step 5 - Validate The Install
Step 5 – Validate The Install

Once installed, create a new WordPress Post and follow the instructions below to insert a new document viewer.

Step 6 - Insert A Doc Conversion API Widget Into Your Post
Step 6 – Insert A Doc Conversion API Widget Into Your Post
Step 7 - Get Your Document Viewer Code And Paste It Into The Plugin Window
Step 7 – Get Your Document Viewer Code And Paste It Into The Plugin Window

To get your embedded document widget code, read this post.

Step 8 - Publish Your Post To Embed Your Document
Step 8 – Publish Your Post To Embed Your Document

Voila! – you’re done.

Why Doc Conversion API?

Good question, thanks for asking!

We started out with a simple set of goals at Doc Conversion API

  1. To provide the best document rendering quality of any online document conversion API
  2. To provide a simple API that let us do all of the most obvious document manipulation tasks
  3. To provide a super simple UI that allows all levels of user interact with Doc Conversion API
  4. To support the most used document formats
  5. To provide a rich and simple to use HTML5 document viewer

Over the next few posts we’ll walk you through our thinking and how we achieved these goals.

 

What is an HTML5 Document Viewer?

The world is moving fast and the web even faster. Standards and technologies change on an almost daily basis. Using an HTML5 Document Viewer can help you in your day-to-day website needs, but how?

An example of this ever shifting landscape is when Steve Jobs went to war on Adobe’s Flash technology – Thoughts on Flash – Steve listed in over 1500 words why he believed Flash should be a thing of the past, why it was never a good idea and what would replace it.

In steps HTML5, In Steve’s own words:

Apple has adopted HTML5, CSS and JavaScript – all open standards. Apple’s mobile devices all ship with high performance, low power implementations of these open standards. HTML5, the new web standard that has been adopted by Apple, Google and many others, lets web developers create advanced graphics, typography, animations and transitions without relying on third party browser plug-ins (like Flash).

This among other reasons is why we’ve build Doc Conversion API, our aim is to provide a HTML5 document viewing experience that does away with power hungry plugins that result in instability in your browser of platform.

HTML5 Document Viewer
An Excel spreadsheet rendered inside our HTML5 Document Viewer

Features of Doc Conversion APIs HTML document viewer include:

  • Multiple Document Format Support
    • Most common file formats including PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, MSG files and many many more.
  • Cross-platform compatibility
    • Your end users will be able to view documents from any web-enabled device that has an HTML5 capable browser, including
      • IE8+, Microsoft Edge,Chrome, Chrome for Android, Firefox, Safari 5+, Mobile Safari
  • Supported Devices
    • iPhone / iPad
    • Android smartphones and tables
    • Windows Mobile
    • PC + Mac
  • HTML5 based text rendering
    • You’ll be able to select, copy and paste text from within your documents
    • This also enables find and highlight functionality within your documents
  • A easy to use Web UI – NO PLUGINS NEEDED!
    • Scroll through your documents easily
    • Simple and intuitive thumbnail view
    • Landscape and portrait document views are supported
    • Download your documents or print them from the browser
  • Super easy to install and deploy
    • Install our HTML5 document viewer in around 6 minutes (That was our fastest deployment yet!)
    • No downloads or installs for your customers to wrestle with
    • Fully feature REST API, allowing you to embed the HTML5 document viewer within your own apps
    • On-premise or cloud based install
    • WordPress, Umbraco, Dot Net Nuke, HTML Website, PHP website support
  • Super friendly and English speaking support team

If you’re looking for a lightweight, easy to install HTML5 Document Viewer for your website or application, just sign up for a free account or get in touch, we’ll be really happy to show you around.