Reputation: 23
I'm trying to convert a HTML page which contains Javascript (that formats certain information after the document is loaded) to PDF, using PHP prefarably.
The javascript code will look something like this:
$(document).ready(function() {
formatProfile();
});
This will format the raw data and replace it to the specific DIV.
However, when I do a render and try to convert it to PDF the DIV remains empty, as if the javascript component is not rendered at all.
I've tried using mpdf, wkhtmltopdf, dompdf and many more but none work as intended. Is there any library that will work or is there any workaround (assuming I still prefer to use the javascript to process and output the results to DIV)?
Upvotes: 2
Views: 3722
Reputation: 34
PDFreactor 6 can convert HTML to PDF and process the JavaScript. It also provides a PHP wrapper.
Upvotes: 0
Reputation: 12038
PhantomJS is probably your best bet here. You'll have to install the software on your server, but it gives a nice implementation of webkit in a headless setup so that you can completely render a page, javascript included and then capture the screen output to a PDF.
EDIT:
You might look at this PHP project which wraps the PhantomJS application in a PHP script for easier web screen capture from within PHP.
Upvotes: 1
Reputation: 2069
You can try this http://www.tcpdf.org/ . Site providing some good examples and also you can design page layout as your own styles. I think this will solve your issues.
Upvotes: 1