6

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.

saiyan101
  • 610
  • 4
  • 12
  • 28

4 Answers4

3

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.

SWilk
  • 3,261
  • 8
  • 30
  • 51
1

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/

1

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

Community
  • 1
  • 1
Hariharan
  • 3,191
  • 4
  • 19
  • 31
0

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.

Ankit
  • 3,083
  • 7
  • 35
  • 59