Convert PDF to Word (DOC , DOCX) Using REST API

With our latest addition to our conversion list, you can now convert your PDF documents to word documents using our REST API. This will allow you to Convert PDF to Word (DOC & DOCX), so you can have more control over the document content, you can edit, process, and re-format these documents easily after conversion. You can also make use of our REST API for other conversions after processing and editing your documents.

PDF to Word

PDF to Word conversion is not an easy job, and even though there are a number of tools that can do this conversion, you will often see them compromise on your document format or quality, Which is not ideal, especially when often, the main purpose of converting the document to word would is to preserve the formatting and make edits without having to start from scratch. This is why Doc Conversion API will always bring you the very best quality in your conversion.

Before                                                   After

pdf to word    PDF to Word

Our conversion API is seriously simple, secure, fast, and accurate, it works with on all computers, systems, and languages, as we welcome all platforms.

Convert PDF to Word using REST API (curl)

Doc Conversion API prides itself in being easy to use and integrate with all programming languages and frameworks; you can find a list of code examples here.

In order to convert from PDF to Word (Doc & Docx), all you need is a simple POST request, using the conversion URL along with your APP credentials (Application ID and Secret Key).

PDF to DOC

If you’re looking to convert PDF to DOC, you will need to use the following URL:

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

And write the following curl request:

curl --request POST \
  --url 'https://api.docconversionapi.com/convert?outputFormat=doc' \
  --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 Your application ID
X-SecretKey Your secret key
OutPutFormat DOC
InputFile The file you would like to convert
optionsJSON a JSON String containing any additional options relevant to the conversion type

 

 

PDF to DOCX

Similarly, If you’re looking to convert PDF to DOCX, you will need to use the following URL:

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

And write the following curl request:

curl --request POST \
  --url 'https://api.docconversionapi.com/convert?outputFormat=docx' \
  --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 Your application ID
X-SecretKey Your secret key
OutPutFormat DOCX
InputFile The PDF file you would like to convert
optionsJSON a JSON String containing any additional options relevant to the conversion type

 

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

Convert DOC to JPEG Using a REST API

Do you have a DOC file and would like to take snapshots of all the pages?, maybe use them as thumbnails? Suppose you have a Word document with 100’s of pages, it would be a tedious task to manually convert every page into an image. That’s why you need our DOC to JPEG converter API, as it will automatically convert every page of the DOC file as JPEG image without the need for any additional software.

Doc to jpeg

Doc Conversion API offers an easy to use, fast, secure, and reliable REST API that you can connect to, and convert any Word DOC to a JPEG image while maintaining formatting and quality. Our API is carefully designed with a focus on quality and reliability. It is simple to execute, however, it is also highly flexible and can be configured to carry out heavy and complex conversions with maximum accuracy.

Convert DOC to JPEG using the REST API (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 DOC to JPEG 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=jpeg

To make the following curl request:

curl --request POST \
  --url 'https://api.docconversionapi.com/convert?outputFormat=jpeg' \
  --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={"pages" : "all"}'

X-ApplicationID is your Application ID

X-SecretKey      is your Secret Key

OutPutFormat is JPEG

InputFile         is the file you would like to convert

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

Convert DOC to JPEG using the REST API (PHP)

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

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

We’re going to be using this example:

http://www.snee.com/xml/xslt/sample.doc

DOC to JPEG

We’re going to create a simple PHP page that reads the Doc file from a URL, and converts this file into a JPEG image that is displayed as a web page:

doc to jpeg

Download this page / View this page

 

This code will execute the conversion, and display the Word DOC content as a JPEG page.

doc to jpeg

 

 

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

New Feature: Electronic Signature Using REST API (for PDF documents)

Continuing with our mission to bring accurate, reliable and easy to use Doc Conversion API, and provide a single stop location for all your document operations, we have now released our new electronic signature feature.

This new Electronic Signature feature enables end users to electronically sign your PDF documents, allowing you to fully digitalize and automate your business process, and eliminate unnecessary time and costs. Electronic Signature also enhances the security of the entire business process and improves user experience and satisfaction.

Doc Conversion API’s Electronic signature is fast, green, secure and extremely convenient, contributing to an improved overall experience.

 

Electronic Signature using REST API (Curl)

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

You can easily sign PDF documents using Doc Conversions’ REST API by making a simple POST request that contains the following elements:

  1. API endpoint: https://api.docconversionapi.com/sign
  2. Application ID and Secret Key: These are your app credentials that you get from your Doc Conversion API dashboard.
  3. Inputfile: This is the file you would like to sign
  4. Signature: The URL/file that directs to your signature file (.png, .svg, etc).
  5. Certificate: The URL/file that directs to your SSL certificate file (.pfx,).
  6. optionsJSON: a JSON object that contains values of your signature details, this can contain:
  • signatureX: An integer value that specifies the horizontal location of your signature.
  • signatureY: An integer value that specifies the vertical location of your signature.
  • signatureWidth: An integer value that specifies the width of your signature image.
  • signatureHeight: An integer value that specifies the height of your signature image.
  • Reason: This is a text string that specifies the reason for signing.
  • Contact: The person who authorized the signature.
  • signerLocation: The location of the signer.
  • Visible: A Boolean value that specifies whether or not the signature should be visible on the document.
  • certificatePassword: The password used to authenticate the certificate.

Once we have these values, we can combine now all elements together, to form our POST request in curl, the curl should look like the following:

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={
               "signatureX":"400",
               "signatureY":"0",
               "signatureWidth":"180",
               "signatureHeight":"140",
               "reason":"Test signature",
               "contact":"YOUR_CONTACY",
               "signerLocation":"YOUR_SIGNER_LOCATION",
               "visible":"true",
               "certificatePassword":"YOUR_CERTIFICATE_PASSWORD"
                                 }' \
  --form signatureAppearance=undefined \
  --form certificate=undefined \

Please note that you would need to replace the values with your preferred values/details.

This request should return a sign PDF file that you can further use in your operations.

To demonstrate how the signature will look, we used a PDF test document that looks like this:

Document without electronic signature

After sending the above POST request, we received the signed document which now looks like this:

electronic signature

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

Convert Your Local Files Using Doc Conversion REST API

At Doc Conversion API, we want to make all conversions and document operations as easy as possible, so we decided to save you the worry of having to have specific storage configuration, as you can use local files, or files stored on the cloud.

As we’ve explained how to use cloud storage files in previous blogs, this time we’re going to focus on using a local file in your conversion, so you can use your own files that are stored on your local computer.

Using the REST API Calls to Convert Local Files


This method is most suitable for backend conversion and processing of documents, if you have a recurring conversion type or want to convert a large number of files, and would like to automate your conversion process.

As explained in previous blog posts, you can use files stored on the cloud, or files with direct download URL, but in this example, we’re going to use a file that is stored on your local disk.

Since our servers will not have direct access to local storage, we need to send an array of bytes that contains all the information about the file to the end-point.

The first step would be to locate the file you would like to use, and get the full path of the file. For simplicity, we’re going to be a word document file called “sample” and stored in the documents folder, but you can use any file and store it anywhere you would like, as long as you’re able to specify the correct path. So the path for our file will be:
/Users/MacBookPro/Documents/sample.doc

Location of local file

The file looks like this:

Local word file

Now we have the file path, we can go ahead and use it in our code, below is a sample PHP code that will perform a simple doc to HTML conversion, create an HTML file, and return, “operation completed successfully” when the conversion is done.

 <?php
 $ch = curl_init();
 $path = 'fl.html';
 $file_name_with_full_path = "/full/path/to_file/fileName.docx";

curl_setopt($ch, CURLOPT_URL,"https://api.docconversionapi.com/convert?outputFormat=html");
 curl_setopt($ch, CURLOPT_POST, 2);
 curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-ApplicationID: ','X-SecretKey: '));

if (function_exists('curl_file_create')) { // php 5.5+
 $cFile = curl_file_create($file_name_with_full_path);
 } else { //
 $cFile = '@' . realpath($file_name_with_full_path);
 }

$post = array(
 "optionsJson"=>"{}",
 "inputFile"=> $cFile
 );

curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 $server_output = curl_exec($ch);

if($server_output === false)
 {
 echo 'Curl error occurred: ' . curl_error($ch);
 }
 else
 {
 echo 'Operation completed successfully';
 }

// save PDF buffer
 file_put_contents($path, $server_output);
 ?>

Make sure to replace the path with the valid path to your file, and update your Application ID and Secret Key (you can get those from your Doc Conversion API dashboard).

After executing this code, you should now have a converted HTML file on your local disk. Our output for this example looks like this:

converted local file HTML

 

You can, of course, customize the code sample enough to fit your needs. More code examples can be found on our documentation page, and specific conversion examples can be found on our blog.
If you need any further help, please contact us at [email protected]occonversionapi.com.

Convert Your Local files using Doc Conversion API (web app)

At Doc Conversion API, we want to make all conversions and document operations as easy as possible, so we decided to save you the worry of having to have specific storage configuration, as you can use a local file, or any files stored on the cloud.

As we’ve explained how to use cloud storage files in previous blogs, this time we’re going to focus on using a local file in your conversion, so you can use your own files that are stored on your local computer.

Using the Web App to Convert Local Files

If you’re looking to use an intuitive interface for a quick conversion, without the need to write code or test connections etc, then this is the right method for you, it’s quick, easy, and requires no configuration.

  1. Login to your Doc Conversion API dashboard and click on Files.
  2. From the Files, window click on File Import.

Choose a Local file

  1. Select the file you’d like to convert and click on choose.

choose a local file

  1. This will upload the file to your dashboard and add it to the file list.
  2. To convert the file, click on the PDF icon under the convert tab.

convert a local file

  1. This will create a new PDF file and add it to your file list.

Converted Local file

You can now download the converted PDF file or use the HTML viewer to view or embed this file in your web page.

If you need any further help, please contact us at [email protected].

New Feature: Find and Replace Words Using REST API

Following our recent release of the word count feature, we are happy to announce that we have now released a Find and Replace feature, for word documents.

We at Doc Conversion API, are focused on our customers and their success, and we believe that our success is represented by our customers’ success. That is why we listen to our customers’ needs and requests, and we spend our working hours analyzing and developing ways to bring these requests to life, while still maintaining the ease of use and reliability of our tools.

Almost everybody who uses a computer knows to how search for words in a document; however, you would need a special software to read this documents almost 99.9% of the time.

On top of that, the process of opening every document, searching for the words, and replacing them, can be quite time consuming, and as with everything, the more documents you have, the harder it becomes to remain accurate and maintain the same levels of efficiency.

This is why we have taken it upon ourselves to build a highly reliable, flexible yet simple, REST API to find and replace words in your documents. With this new feature, you can now easily find and replace any amount of words with a single API call, saving you’re the time and effort, and providing you great accurate results that you can immediately integrate in your process, without having to worry if you had missed anything.

Using The REST API to Find and Replace Words (CURL)

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

You can simply find and replace any words in your documents by making a POST request, using the below URL Along with your APP credentials (Application ID and Secret Key):

https://api.docconversionapi.com//utility/replace

To make the following curl request:

curl --request POST \
  --url 'https://api.docconversionapi.com//utility/wordcount' \
  --header 'X-ApplicationID: <Your_Application_ID>' \
  --header 'X-SecretKey: <Your_Application_SecretKey>' \
  --header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  --form inputFile= <INPUT FILE PATH> \
  --form optionsJSON= {"searchItems": "OLD_WORD", "replaceItems": "NEW_WORD", "matchCase": "true", "matchWholeWord": "true"}'

Where:

X-ApplicationID   is your application ID

X-SecretKey                 is your secret ky

OutPutFormat   is HTML

InputFile          is the file you would to like to convert

optionsJSON    is a JSON String containing the word you would like to search and the word you would like to replace it with.

Using The REST API to Find and Replace Words (PHP)

Doc Conversion API is compatible with all main 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 would like to use the find and replace feature for) for simplicity; you can also upload documents to the service or use your own linked storage files.

We’re going to be using this example:

https://www2.cdc.gov/cdcup/library/templates/CDC_UP_Test_Plan_Template.doc

Find and replace word example

We’re going to create a simple PHP page that reads the Doc file from a URL, and finds the word Test, and replaces it with new-test.

Find and replace PHP code

Download this page / View this page

This code will search for the word “Test”, and replace it with “new-test” in a newly created file.

output document after Find and Replace

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

New Feature: REST API for Word Count

We at Doc Conversion API, continue to develop new features that will bring value to our customers and enhance their experience. That’s why we’re happy to announce that we have now released a new word count feature for word documents (.doc, .docx, etc).

The new word count feature has been highly requested by our customers, and we believe that it will make a big difference, as it is super simple, accessible and easy to use. Anyone can use it, even without any programming background.

Finding your word count is easy if you have a single document or two, but when you have a large number of documents to process and go through, it can be quite time consuming and it becomes increasingly difficult to maintain accuracy.

Instead of writing long pieces of code and wasting your time going through the iterations of testing and optimizing your code, we have now created an optimum solution for you; an easy to use, highly reliable, REST API that you can just call into with a few simple lines, to get your documents word count.

This feature will give you the exact number of words in your documents, and it supports Word documents only at the moment, so extensions like (.doc, .docx, etc) are all supported, with clear plans of expanding this feature in the future to cover more document formats.

Using the REST API to find your word count (CURL)

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

You can simply find the word count for your documents by making a POST request, using the below URL Along with your APP credentials (Application ID and Secret Key):

https://api.docconversionapi.com//utility/wordcount

To make the following curl request:

curl --request POST \
 --url 'https://api.docconversionapi.com//utility/wordcount' \
 --header 'X-ApplicationID: <Your_Application_ID>' \
 --header 'X-SecretKey: <Your_Application_SecretKey>' \
 --header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
 --form inputFile= <INPUT FILE PATH> \
 --form optionsJSON=

Where:

X-ApplicationID is your application ID

X-SecretKey                 is your secret ky

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 request type.

Using the REST API to find your word count (PHP)

Doc Conversion API is compatible with all main 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 would like to find the word count for) for simplicity; you can also upload documents to the service or use your own linked storage files.

We’re going to be using this example (this document has 39 words):

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

We’re going to create a simple PHP page that reads the Doc file from a URL, and finds the total number of words in this file:

PHP code to get the word count using Doc Conversion APIDownload this page / View this page

 

This code will execute the word count, and display the number of words (769) as an HTML page.

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

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.