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.
-
did you try anything? – Shijin TR Apr 19 '13 at 07:19
-
i use this to create a PDF from some html template: https://code.google.com/p/wkhtmltopdf/ – Davor Mlinaric Apr 19 '13 at 07:21
4 Answers
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.

- 3,261
- 8
- 30
- 51
Follow the Link of Zend_Pdf : http://framework.zend.com/manual/1.12/en/zend.pdf.html
You can also try jspdf : http://jspdf.com/
i unable to get your requirement, i hope you require to take pdf of web page.
if my understanding is correct, Please refer below link
http://www.hiqpdf.com/demo/ConvertHtmlToPdf.aspx
also see the existing post ITextSharp HTML to PDF?
Thanks
Use wkhtmltopdf for this purpose. I am using it to generate pdf of html pages.
But it is not possible alone with javascript. You have to have some server side code for the same.

- 3,083
- 7
- 35
- 59