How to convert dynamic content of html page to pdf
In the html page, some tags are dynamically created using jquery and the content is loaded from msql db using jquery and php. I want to convert this dynamic page to pdf. I have tried the following code, but it creates a pdf of the static part of the html page.
<?php
ob_start();
?>
//html code and internal css, javascript used in external file with jquery library
<?php
include('dompdf/dompdf_config.inc.php');
$contents = ob_get_contents();
ob_end_clean();
$dompdf = new DOMPDF();
$dompdf->load_html($contents);
$dompdf->render();
$dompdf->stream('file.pdf');
?>
So how to store the content of a dynamic html page in a php variable after processing it (using javascript / php) and convert it to pdf usin dompdf or another converter.
source to share
This may not match exactly what you are looking for, but wkhtmltopdf may be what you need. Since PHP is server-side technology, you will have a hard time handling any client-side javascript. wkhtmltopdf scans the page, javascript and that's it and then creates a PDF file on the server. Hope this helps you!
source to share
With a tool like wkhtmltopdf it is possible to directly generate a PDF page. It will run the javascript and generate the page as WebKit will render it.
source to share