How to Rasterize a PDF in C/C++
While all PDF files are relatively secure compared to text editors and other such fungible formats, rasterized (image-based) PDFs are completely un-editable images, whereas vector PDF files still contain compartmentalized text and multimedia data.
You can take advantage of a free API that automatically converts vector PDF files to raster PDF files using the complementary C/C++ code examples below. This will make it easy to incorporate a low-code PDF security measure in your relevant file processing applications.
Start by installing Libcurl in your C/C++ project:
libcurl/7.75.0
Then copy the below examples to structure your API call:
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/pdf/rasterize");
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);
You can use up to 800 API calls per month with a free API key; this can be retrieved by setting up a free account on the Cloudmersive website.
Now you can add a simple, low-code PDF conversion service into any of your file processing applications.