Do you have a product or item that needs a barcode, but the area is too small to contain the standard UPC-A format? If your answer is yes, the UPC-E barcode option may be the solution you’re looking for; with only six digits, it’s half the length of the UPC-A option. To create this condensed barcode, you can use the following API in C/C++ to generate a UPC-E barcode image.
Let’s start by installing libcurl:
Now, we can call our function with the following code:
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.cloudmersive.com/barcode/generate/upc-e");
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 = "0=%3C&1=s&2=t&3=r&4=i&5=n&6=g&7=%3E";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
At the end of this quick process, your new barcode will be ready as a downloadable PNG file!