13

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?

insertusernamehere
  • 23,204
  • 9
  • 87
  • 126
Vishnu
  • 141
  • 1
  • 1
  • 3

3 Answers3

3

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

chandru
  • 55
  • 1
  • 8
1

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

Prateek Chandan
  • 107
  • 2
  • 11
1

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!

Community
  • 1
  • 1
Vikram
  • 4,162
  • 8
  • 43
  • 65