Skip to content

Commit

Permalink
Ajoute www2pdf lecteur de page et output sur stdout au format pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaudeStabile committed Jan 25, 2023
1 parent a6c5be8 commit 978cd90
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Binary file added www2pdf
Binary file not shown.
30 changes: 30 additions & 0 deletions www2pdf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>

int main(int argc, char *argv[]) {
if (argc != 2) {
printf("Usage: %s <URL>\n", argv[0]);
return 1;
}

CURL *curl;
FILE *fp;
char outfilename[FILENAME_MAX] = "output.html";
char command[FILENAME_MAX + 100];

curl = curl_easy_init();
if (curl) {
fp = fopen(outfilename,"wb");
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(fp);
}
snprintf(command, sizeof(command), "wkhtmltopdf --no-background %s -", outfilename);
system(command);
remove(outfilename);
return 0;
}

0 comments on commit 978cd90

Please sign in to comment.