-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdftables.c
More file actions
51 lines (40 loc) · 1.28 KB
/
pdftables.c
File metadata and controls
51 lines (40 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
int main(int argc, char *argv[]) {
CURL *curl;
CURLcode res;
struct curl_httppost *formpost = NULL;
struct curl_httppost *lastptr = NULL;
res = curl_global_init(CURL_GLOBAL_ALL);
if (res != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed: %s\n", curl_easy_strerror(res));
exit(1);
}
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "f",
CURLFORM_FILE, "example.pdf",
CURLFORM_END);
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "filename",
CURLFORM_COPYCONTENTS, "example.pdf",
CURLFORM_END);
curl = curl_easy_init();
if (!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
exit(1);
}
curl_easy_setopt(curl, CURLOPT_URL, "https://pdftables.com/api?key=YOUR_API_KEY&format=xml");
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
exit(1);
}
curl_easy_cleanup(curl);
curl_formfree(formpost);
return 0;
}