View Full Version : converting ajax/php driven site to PDF

01-25-2011, 11:56 PM
I want to create a link on my ajax/php driven website that can be clicked on and will take the current page and convert it to pdf.

I have tried using dompdf but from what I can tell, it doesn't have the ability to render something dynamic with ajax. It only takes the whole file on the server and converts it and since the page being viewed is actually made up of several files it doesn't know how to preform the same results like the web browser.

I am wondering if there would be some kind of work around for this?

Any suggestions?

01-26-2011, 03:16 PM
Well.. there's got to be a better way than this, but one approach might be just to grab the entire generated contents of your HTML tag, and fire that at your PHP script. In jquery:

var full_source = $('html').html();
$.post('html_to_pdf.php', {
source_html: full_source

Something along those lines?

02-05-2011, 10:28 PM
Just add this code to your pages:

<a href="http://pdfcrowd.com/url_to_pdf/">Convert this page to a PDF</a>

Here is an explanation how it works: http://pdfcrowd.com/save-to-pdf/.