Javascript: PDF export button for webpage

javascript

Solution

I think there is no javascript library which would allow to create a pdf file. Mozilla implemented complete PDF reader in js and includes it in latest Firefox, but that is huge library. EDIT: there is jspdf which seems to be able to do that.

I think you should go with server side PDF engine.

DOMPdf is a PHP library which allows to render complete HTML with CSS, images etc to PDF document. It even has a example php script which put on server allows to convert submited html to PDF.

Your javascript "button" should just get the document.getElementsByTagName('html')[0].innerHTML and post that HTML to the DOMPdf script. You should get more or less correct PDF out of this.

Problem

I would like any pointers or resources to where I can get a java-script that allows my export button on my site to export my current page to pdf.

Original source

Related problems