How to Append a Heading to an HTML Document using C/C++

Cloudmersive
2 min readAug 9, 2023

--

Headings in HTML documents can vary dramatically in size and styling. Even with the use of standardized CSS stylesheets and other linked documents, it can be difficult to standardize the headings of multiple HTML documents at once. Thankfully, using the below code, you can specify heading text contents, text size, and text styling for any HTML file through a quick API request.

You can use values of 1 through 6 (integers) to specify the size of the heading, and you can include your own CSS styling code to specify what each heading should look like.

To structure your API call, start by installing libcurl in your C/C++ project:

libcurl/7.75.0

After that, copy the below code to structure your request, and provide a free-tier Cloudmersive API key in the authorization header:

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/html/append/heading");
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, "inputFileUrl: <string>");
headers = curl_slist_append(headers, "headingText: <string>");
headers = curl_slist_append(headers, "headingSize: <integer>");
headers = curl_slist_append(headers, "cssStyle: <string>");
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 = "inputFile=%3Cbinary%3E";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);

Now you can easily make programmatic edits to HTML documents at scale.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet