<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://pdf-generator.online/api/convert/html/pdf',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"file_url": "http://acme.com/",
"scale": 1,
"waitUntil": "load"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-PDFOnline-ApiKey: apiToken'
),
));
$response = curl_exec($curl);
curl_close($curl);
file_put_contents('output.pdf', $response);
curl --location --request POST 'https://pdf-generator.online/api/convert/html/pdf' \
--header 'Content-Type: application/json' \
--header 'X-PDFOnline-ApiKey: apiToken' \
--data-raw '{
"file_url": "http://acme.com/",
"scale": 1,
"waitUntil": "load"
}' --output output.pdf
Unirest.setTimeouts(0, 0);
File response = Unirest.post("https://pdf-generator.online/api/convert/html")
.header("Content-Type", "application/json")
.header("X-PDFOnline-ApiKey", "c0f8a4efca-3d8a7d9e5f-c69c9ef3b6-dae10b77dd")
.body("{\n \"file_url\": \"https://acme.com\",\n \"save\": \"0\"\n}")
.getBody();
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-PDFOnline-ApiKey", "apiToken");
var raw = "{\n \"file_url\": \"http://acme.com/\",\n \"scale\": 1,\n \"waitUntil\": \"load\",\n}";
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://pdf-generator.online/api/convert/html/pdf", requestOptions)
.then(response => response.blob())
.then(result => {
var blob = new Blob([result], {type: "application/pdf"});
var link=document.createElement('a');
link.href=window.URL.createObjectURL(blob);
link.download="myFileName.pdf";
link.click();
})
.catch(error => console.log('error', error));