We can easily edit and manipulate DOCX documents at will by using libraries that interact directly with the file structure. We can even create them from scratch using the ready-to-run C/C++ code below. This operation returns a blank DOCX format file with zero contents whatsoever, and we can easily fill that document with content using other Cloudmersive Document Conversion APIs.
We can structure our API call by first installing Libcurl in our project:
libcurl/7.75.0
And then copying the below code into our file & authenticating our request with a free-tier Cloudmersive API key:
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.cloudmersive.com/convert/edit/docx/create/blank");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
headers = curl_slist_append(headers, "Apikey: YOUR-API-KEY-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "InitialText=%3Cstring%3E";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
>
curl_easy_cleanup(curl);
We can use our blank DOCX file as the basis for creating forms, contracts, and other standardized documents.