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.

+3


source to share


4 answers


I would suggest you take a look at wkhtmltopdf. I have had good results in order to display google charts that are dynamically generated from the javascript api.



http://code.google.com/p/wkhtmltopdf/

+2


source


As Mark said you need to read the generated DOM with javascript .. something like $('html').html()

and then send it to php to generate pdf



+1


source


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!

0


source


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.

0


source







All Articles