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]