I have a website with HTML/CSS and a JavaScript generated inline datepicker. You can mark days in datepicker.
I want to export the whole content with the marks in datepicker as a PDF.
With Client-Side jsPDF and canvas2html I have a problem with position and sizes. I get partial content in the PDF only (begin or end from datepicker).
Now I try it with wkhtmltopdf.
I get the HTML with $("#datepicker").html() and send it to a PHP Script. It works with a test string, but I get a blank pdf when I use real data.
$.ajax({
data: 'htmlstring=' + escape($("#datepicker").html()),
url: 'http://example.com/htmltopdf.php',
method: 'POST',
success: function(msg) {
alert(msg);
}
});
<?php
$htmlString = $_POST["htmlstring"];
//$htmlString = rawurldecode($htmlString);
exec('echo "<html><head></head><body>' . $htmlString . '</body></html>" | /usr/local/bin/wkhtmltopdf --encoding UTF-8 - export.pdf');
?>
I also like a different working solution.