<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<a href="">
<span>Текст или символ который надо о центру</span>
</a>
</body>
</html>
a{
display: flex;
justify-content: center;
align-items: center;
}
let element = document.getElementById('route-container');
html2canvas(element, {dpi: 144, letterRendering: true}).then(function(canvas) {
console.log(canvas)
let img = canvas.toDataUrl("image/png");
var pdf = new jsPDF('l', 'pt', [1920, 1080]);
pdf.addImage(img, 'png', 40);
pdf.save('test.pdf');
})
$('#save_route').click(function(event) {
startPreloader();
$.ajax({
url: '/wp-admin/admin-ajax.php',
type: "POST",
data: "action=get_pdf",
success: function(response){
console.log(response);
stopPreloader();
}
});
});
function get_pdf(){
$apikey = 'e9c18905-cf-9a58-5cebbd9826d1';
$value = 'yandex.ru';
$result = file_get_contents("http://api.html2pdfrocket.com/pdf?apikey=" . urlencode($apikey) . "&value=" . urlencode($value));
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . strlen($result));
header('Content-Disposition: attachment; filename=' . 'alias-name.pdf' );
echo $result;
wp_die();
}