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]