I am using dompdf and php to create a pdf page, this works fine when I pass some html to it i.e.
But I want to pass the html of the page to it, which is where I was hoping javascript (jquery is running on the site) would help.
I was thinking that the user would click a link 'click here to save this page as pdf' which would then fire a form submission back to the same page so I could do something like
which would output the html of the page.
My question is, how do I do the javascript part to grab the html of the page and submit it if the users click a link to generate the pdf? Is this a good way of going about it?
Thanks
Code:
<?php
require_once("dompdf/dompdf_config.inc.php");
$html ='<html><body>'.
'<p>sample pdf</p>'.
'</body></html>';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
?>
But I want to pass the html of the page to it, which is where I was hoping javascript (jquery is running on the site) would help.
I was thinking that the user would click a link 'click here to save this page as pdf' which would then fire a form submission back to the same page so I could do something like
Code:
<?php
require_once("dompdf/dompdf_config.inc.php");
$html = $_POST['pagecode'];
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
?>
which would output the html of the page.
My question is, how do I do the javascript part to grab the html of the page and submit it if the users click a link to generate the pdf? Is this a good way of going about it?
Thanks