Liad Livnat Liad Livnat - 1 year ago 83
AngularJS Question

Is it possible to export html content to PDF from client side?

I'm facing an issue trying to add my website export to PDF function.

When browsing the net, i found some solution, but non of them is just printing the page as is to PDF. can't take pure html and make it into pdf file.

I know there is many questions regarding the issue, but there is no one clear answer to the question: Is it possible to export html content to PDF from client side.

if it's possible i will be glad to know how.

if not please suggest how should i do it from server side (java / php / node.js) .

please note that the page contains highcharts charts and images: you can have a look in here:

Answer Source

I use DOMPDF which takes inline PHP and uses it to convert all of your HTML markup (CSS as well) to PDF. You can implement it client side using a button at the end of your page.






$content = $_POST['html'];



        $error = 'Please include at least ONE completed field.';





        $dompdf = new DOMPDF();








<input type="submit" name="submit" id="submit" value="Generate PDF" class="submitButton">

Here is an informative video on how to use DOMPDF and where to download the necessary files.