How to Convert PowerPoint PPTX to PNG using C/C++
PowerPoint PPTX files are notoriously bulky, so an array of slides can be difficult to share across networks efficiently. Thankfully, when we convert PPTX files to PNG, we eliminate that problem and make it easy to show iterations of our projects while protecting against unwanted external edits.
You can use the ready-to-run C/C++ code below to take advantage of a free API that automatically converts PPTX documents into PNG image arrays (one image per slide). You can easily incorporate this service into your document processing applications in two quick steps.
To get started, you’ll need to install libcurl in your project:
libcurl/7.75.0
After that, you can copy the below examples (and you’re almost done):
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/pptx/to/png");
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: multipart/form-data");
headers = curl_slist_append(headers, "Apikey: YOUR-API-KEY-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_mime *mime;
curl_mimepart *part;
mime = curl_mime_init(curl);
part = curl_mime_addpart(mime);
curl_mime_name(part, "inputFile");
curl_mime_filedata(part, "/path/to/file");
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
res = curl_easy_perform(curl);
curl_mime_free(mime);
}
curl_easy_cleanup(curl);
Now you just need to authenticate your request by providing a free-tier API key in the “Apikey” header. This will allow up to 800 API calls per month with no additional commitment, and you can get one by registering a free account on the Cloudmersive website.