I want to create a PDF document from HTML in JavaScript. I tried using the library jsPDF
but all the HTML formatting are not supported in it. Is there any other library that I can use to create the PDF?

- 23,204
- 9
- 87
- 126

- 141
- 1
- 1
- 3
-
use pdf.js http://mozilla.github.com/pdf.js/web/viewer.html – Nishant Jani Feb 08 '13 at 10:53
-
i want to pass a html content and produce a resulting pdf from it.Is it possible using pdf.js.I was only able to render a pdf document to a html page using it. – Vishnu Feb 08 '13 at 12:22
-
yes yes you can create a new pdf using pdf.js , please read their documentation – Nishant Jani Feb 08 '13 at 12:30
-
http://bytescout.com/products/developer/pdfgeneratorsdkjs/create_pdf_invoice_javascript.html – Hary Feb 08 '13 at 13:01
-
was there ever a answer to this question? – Matt Aug 27 '13 at 18:06
3 Answers
I've just written a library called jsPDF (Give you the link below) which generates PDFs using Javascript alone. It's still very young, and I'll be adding features and bug fixes soon. Also got a few ideas for workarounds in browsers that do not support Data URIs. It's licensed under a liberal MIT license.
I came across this question before I started writing it and thought I'd come back and let you know :)
http://code.google.com/p/jspdf/
http://hayageek.com/generate-pdf-with-javascript/ //Try this link with step by step process

- 55
- 1
- 8
You can create the html page as you like to have PDF then from javascript you can call print function of the browser which eventually exports a webpage to a pdf or in printable form

- 107
- 2
- 11
Consider installing gitbook-pdf
gitbook-pdf
uses PhantomJS
and rasterize.js
to build PDF
files from HTML
You would require NodeJS and NPM
After installing run commands:
gitbook-pdf --format A4 generate index.html index.pdf
A4 is the default paper format..there are other options too! check it out
index.html is your main HTML file
index.pdf is your final product
Hope that helps!